QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#847558#9874. Matrix Constructionenze114514WA 0ms3792kbC++201.1kb2025-01-08 05:03:152025-01-08 05:03:23

Judging History

你现在查看的是最新测评结果

  • [2025-01-08 05:03:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2025-01-08 05:03:15]
  • 提交

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)