QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#549143#9114. Black or White 2Charizard2021WA 0ms3512kbC++142.0kb2024-09-06 10:23:142024-09-06 10:23:14

Judging History

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

  • [2024-09-06 10:23:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3512kb
  • [2024-09-06 10:23:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n, m, k;
        cin >> n >> m >> k;
        bool transpose = false;
        if(n < m){
            swap(n, m);
            transpose = true;
        }
        int val = (n * m)/2;
        bool transpose2 = false;
        if(val < k){
            k = n * m - k;
            transpose2 = true;
        }
        vector<vector<int> > a(1 + n, vector<int>(1 + m));
        int idx = 1;
        for(int i = 1; i <= m; i += 2){
            if(k > 0){
                a[1][i] = 1;
                k--;
            }
        }
        for(int i = 2; i <= n; i++){
            if(k >= m){
                for(int j = 1; j <= m; j += 2){
                    a[i][j] = 1;
                }
                for(int j = 2; j <= m; j += 2){
                    a[i - 1][j] = 1;
                }
                k -= m;
                idx = i;
            }
        }
        for (int i = 2; i <= m; i += 2){
            if(k >= 2){
                a[idx][i] = 1;
                a[idx + 1][i] = 1;
                k -= 2;
            }
        }
        a[n][m] = k;
        if(transpose){
            for(int i = 1; i <= m; i++){
                for(int j = 1; j <= n; j++){
                    if(transpose2){
                        cout << 1 - a[j][i] << " ";
                    }
                    else{
                        cout << a[j][i] << " ";
                    }
                }
                cout << "\n";
            }
        }
        else{
            for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                    if(transpose2){
                        cout << 1 - a[i][j] << " ";
                    }
                    else{
                        cout << a[i][j] << " ";
                    }
                }
                cout << "\n";
            }
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3512kb

input:

2
2 2 2
2 3 0

output:

1 0 
0 1 
0 0 0 
0 0 0 

result:

wrong answer