QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#807318 | #9874. Matrix Construction | Wzy# | WA | 1ms | 3684kb | C++14 | 1.2kb | 2024-12-09 21:23:35 | 2024-12-09 21:23:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const int N=2e5+10,M=2e6;
const int mod=998244353;
const LL P=1e9+7;
const LL INF=1e18;
LL h[N],e[M],ne[M],w[M],idx;
LL d[N];
int n;
void solve(){
int n,m;
cin>>n>>m;
if(n==m&&n==2){
cout<<"No"<<endl;
return;
}
int res[n+10][m+10];
cout<<"Yes"<<endl;
if(m==2){
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++){
if(i%2) res[j][i]=(i-1)*n+j;
else if(j==1) res[j][i]=i*n;
else res[j][i]=(i-1)*n+j-1;
}
}
else{
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
if(i%2) res[i][j]=(i-1)*m+j;
else if(j==1) res[i][j]=i*m;
else res[i][j]=(i-1)*m+j-1;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++) cout<<res[i][j]<<" ";
cout<<endl;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3640kb
input:
2 1 1 2 3
output:
Yes 1 Yes 1 2 3 6 4 5
result:
ok All test cases passed. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3684kb
input:
361 4 9 11 12 16 14 3 7 17 13 1 19 12 3 15 19 11 3 8 18 13 10 8 13 9 18 14 11 7 13 6 16 12 13 1 6 11 15 18 19 5 6 17 19 2 3 17 11 16 19 6 14 5 9 7 2 5 11 15 16 3 15 7 11 16 2 19 15 5 19 2 17 13 12 3 5 19 14 6 3 18 2 16 4 6 8 10 9 17 4 5 16 17 9 16 11 6 9 16 5 3 19 18 9 13 9 12 19 6 13 17 15 13 7 12 ...
output:
Yes 1 2 3 4 5 6 7 8 9 18 10 11 12 13 14 15 16 17 19 20 21 22 23 24 25 26 27 36 28 29 30 31 32 33 34 35 Yes 1 2 3 4 5 6 7 8 9 10 11 12 24 13 14 15 16 17 18 19 20 21 22 23 25 26 27 28 29 30 31 32 33 34 35 36 48 37 38 39 40 41 42 43 44 45 46 47 49 50 51 52 53 54 55 56 57 58 59 60 72 61 62 63 6...
result:
wrong answer Duplicate sum found for adjacent elements at (1,7) and (1,8) (test case 2)