QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#804295 | #9874. Matrix Construction | ucup-team139# | WA | 0ms | 3552kb | C++14 | 923b | 2024-12-07 21:32:04 | 2024-12-07 21:32:05 |
Judging History
answer
#include <bits/stdc++.h>
#define int int64_t
using namespace std;
vector<vector<int> > solve(int n, int m) {
vector<vector<int> > a(n, vector<int>(m));
int c = 1;
for(int i=0; i<n; ++i) {
for(int j=0; j<m; ++j) {
a[i][j]=c++;
}
}
return a;
}
bool check(vector<vector<int> >& a) {
set<int> s;
int n = a.size();
int m = a[0].size();
for(int i=0; i<n; ++i) {
for(int j=0; j<m; ++j) {
if(s.count(a[i][j])) return 0;
s.insert(a[i][j]);
}
}
return 1;
}
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
/*for(int n=1; n<100; ++n) {
for(int m=1; m<100; ++m) {
auto a = solve(n,m);
if(!check(a)) {
cerr<<"wrong "<<n<<' '<<m<<endl;
return 1;
}
}
}
return 0;
*/
int t;
cin>>t;
while(t--) {
int n,m;
cin>>n>>m;
auto a = solve(n,m);
cout<<"Yes\n";
for(int i=0; i<n; ++i) {
for(int j=0; j<m; ++j) {
cout<<a[i][j]<<' ';
}
cout<<'\n';
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3552kb
input:
2 1 1 2 3
output:
Yes 1 Yes 1 2 3 4 5 6
result:
wrong answer Duplicate sum found for adjacent elements at (1,2) and (1,3) (test case 2)