QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762752#5438. Half MixedfosovWA 0ms3552kbC++141.6kb2024-11-19 16:30:442024-11-19 16:30:44

Judging History

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

  • [2024-11-19 16:30:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-11-19 16:30:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define lll __int128
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>
#define pdd pair<double, double>
#define tdd tuple<double, double, double>
#define N 20
 
vector<int> gen(ll n) {
    assert((n*(n+1)/2) % 2 == 0);
    vector<int> res;
    int x = 0;
    ll tar = n*(n+1)/4;
    for (ll i = n; i >= 1; -- i) {
        ll cur = i*(i+1)/2;
        while (tar >= cur && (tar - cur) >= n - res.size() - i) {
            for (int j = 0; j < i; ++ j) res.emplace_back(x);
            x ^= 1;
            tar -= cur;
        }
    }
    return res;
}

int main() {
#ifdef TEST
    freopen("zz.in", "r+", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t; cin >> t;
    while (t --) {
        ll n, m; cin >> n >> m;

        ll tot = n*m*(n+1)*(m+1)/4;
        if (tot % 2 == 1) {
            cout << "No\n"; continue;
        }

        vector<vector<int>> g(n, vector<int>(m));
        ll x = n, y = m, f = 0;
        if ((x*(x+1)/2) % 2 != 0) swap(x, y), f = 1;

        cout << x << '\n';

        vector<int> r = gen(x);
        for (int i = 0; i < y; ++ i) {
            for (int j = 0; j < x; ++ j) {
                if (!f) g[j][i] = r[j];
                else g[i][j] = r[j];
            }
        }
        cout << "Yes\n";
        for (int i = 0; i < n; ++ i) {
            for (int j = 0; j < m; ++ j) {
                cout << g[i][j] << ' ';
            }
            cout << '\n';
        }
    }
}   

詳細信息

Test #1:

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

input:

2
2 3
1 1

output:

3
Yes
0 1 0 
0 1 0 
No

result:

wrong answer Token "3" doesn't correspond to pattern "Yes|No" (test case 1)