QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#847558 | #9874. Matrix Construction | enze114514 | WA | 0ms | 3792kb | C++20 | 1.1kb | 2025-01-08 05:03:15 | 2025-01-08 05:03:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
const ld pi = 3.14159265358979323846;
const int mod = (int)1e9 + 7;
const ll INF = 1e18;
template<typename T>
T chmax(T a, T b){
return a > b ? a : b;
}
template<typename T>
T chmin(T a, T b){
return a > b ? b : a;
}
const int N = (int)2e5 + 1, M = N * 2;
void solve(){
int n, m;
cin >> n >> m;
vector<vector<int>> a(n, vector<int>(m));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
a[i][j] = i * n + j + 1;
}
if(m % 2 && i % 2){
for(int j = m - 1; j >= 1; j--){
swap(a[i][j], a[i][j - 1]);
}
}
}
cout << "Yes" << endl;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << a[i][j] << " ";
}
cout << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
cin >> t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3792kb
input:
2 1 1 2 3
output:
Yes 1 Yes 1 2 3 5 3 4
result:
wrong answer Duplicated element found in the matrix. (test case 2)