比赛 收心赛 评测结果 AAAAWWWWWWWWWWWWWWWW
题目名称 矩阵游戏 最终得分 20
用户昵称 郑霁桓 运行时间 1.190 s
代码语言 C++ 内存使用 3.89 MiB
提交时间 2026-02-24 12:26:32
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int T,n,m,b[305][305],p;
int main(){
    freopen("matrix.in","r",stdin);
    freopen("matrix.out","w",stdout);
    ios::sync_with_stdio(false);
    cin>>T;
    while(T--){
        cin>>n>>m,p=1;
        for(int i=1;i<n;i++){
            for(int j=1;j<m;j++){
                cin>>b[i][j];
                if(b[i][j]>1e6) p=0;
            }
        }
        if(!p){
            cout<<"NO\n";
        }else if(n<4&&m<4){
            cout<<"YES\n";
            if(n==3&&m==3){
                cout<<b[1][1]<<" 0 "<<b[1][2]<<"\n";
                cout<<"0 0 0\n";
                cout<<b[2][1]<<" 0 "<<b[2][2]<<"\n";
            }else if(n==2&&m==3){
                cout<<b[1][1]<<" 0 "<<b[1][2]<<"\n";
                cout<<"0 0 0\n";
            }else if(n==3&&m==2){
                cout<<b[1][1]<<" 0\n";
                cout<<"0 0\n";
                cout<<b[2][1]<<" 0\n";
            }else if(n==2&&m==2){
                cout<<b[1][1]<<"0\n";
                cout<<"0 0\n";
            }
        }else cout<<"NO\n";
    }
    return 0;
}