QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#168443#5438. Half MixedZhou_JK#WA 0ms3456kbC++231.8kb2023-09-08 15:08:392023-09-08 15:08:40

Judging History

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

  • [2023-09-08 15:08:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3456kb
  • [2023-09-08 15:08:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
long long way(int x) {
    return 1ll * x * (x + 1) / 2;
}

void solve() {
    auto getv = [&](int x) {
        long long w = way(x) / 2;
        cout << x << " " << w << "\n";
        vector<int> lens;
        for (int i = x; i >= 1; i--) {
            if (w >= way(i) + x) {
                lens.push_back(i);
                w -= way(i);
                break;
            }
        }
        // w >= n >= rem
        int rem = x - (lens.empty() ? 0 : lens[0]);
        while (rem < w) {
            for (int j = 10; j >= 2; j--) {
                int ww = way(j) - j;
                if (w - ww >= rem) {
                    w -= ww;
                    lens.push_back(j);
                    break;
                }
            }
        }
        while (rem--) {
            lens.push_back(1);
        }
        return lens;
    };
    int n, m;
    cin >> n >> m;
    if (way(n) % 2 == 1 && way(m) % 2 == 1) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
    if (way(n) % 2 == 0) {
        auto lens = getv(n);
        int p = 0, i = 0;
        vector<int> col(n);
        for (int x : lens) {
            while (x--) col[i++] = p;
            p ^= 1;
        }
        for(int i=0;i<n;i++)for(int j=0;j<m;j++){
            cout<<col[i]<<" \n"[j+1==m];
        }
    } else {
        auto lens = getv(m);
        int p = 0, i = 0;
        vector<int> col(m);
        for (int x : lens) {
            cout<<x<<"\n";
            while (x--) col[i++] = p;
            p ^= 1;
        }
        for(int i=0;i<n;i++)for(int j=0;j<m;j++){
            cout<<col[j]<<" \n"[j+1==m];
        }
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();    
    }
    return 0;
}

詳細信息

Test #1:

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

input:

2
2 3
1 1

output:

Yes
3 3
1
1
1
0 1 0
0 1 0
No

result:

wrong answer Integer parameter [name=M[i][j]] equals to 3, violates the range [0, 1] (test case 1)