QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#667469#5438. Half Mixedadivse#WA 0ms11252kbC++202.9kb2024-10-22 23:20:412024-10-22 23:20:47

Judging History

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

  • [2024-10-22 23:20:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:11252kb
  • [2024-10-22 23:20:41]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#define endl '\n'
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define rep2(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
template<typename T>
void bu(vector<T> tem) { for (auto x : tem) cout << x << ' '; cout << endl; }
void bu(int a) { cout << a << endl; }
void bu(int a, int b) { cout << a << ' ' << b << endl; }
void bu(int a, int b, int c) { cout << a << ' ' << b << ' ' << c << endl; }
void kuaidu() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); }
inline int max(int a, int b) { if (a < b) return b; return a; }
inline int min(int a, int b) { if (a < b) return a; return b; }
using PII = pair<int, int>;
using i128 = __int128;

//--------------------------------------------------------------------------------
const int N = 1e6 + 10;
const int M = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e16;
int n, m, T;
vector<int> D;
//--------------------------------------------------------------------------------


signed main() {
    kuaidu();

    D.push_back(0);
    rep(i, 1, N - 1) {
        D.push_back(i * (i + 1) / 2);
    }

    T = 1; cin >> T;
    while (T--) {
        cin >> n >> m;
        int a = n * (n + 1) / 2, b = m * (m + 1) / 2;
        if (a % 2 and b % 2) {
            cout << "No" << endl;
            continue;
        }
        cout << "Yes" << endl;
        if (a % 2) a = m;
        else a = n;

        vector<vector<int>> A;
        A.resize(n + 10);
        rep(i, 0, n) A[i].resize(m + 10);

        vector<int> tem;
        int cha1 = a * (a + 1) / 4, cha2 = a;
        while (1) {
            int l = -1, r = D.size();
            while (l + 1 != r) {
                int mid = l + r >> 1;
                if (D[mid] + cha2 - mid <= cha1) l = mid;
                else r = mid;
            }
            cha1 -= D[l];
            if (cha1 == cha2 - l) {
                tem.push_back(l);

                rep(i, 1, cha2 - l) tem.push_back(1);
                break;
            }
            cha2 -= l;
            tem.push_back(l);
            if (!cha1) break;
        }

        if (a == n) {
            int id = 1, fl = 0;
            for (auto x : tem) {
                fl = 1 - fl;
                rep(i, id, id + x - 1) rep(j, 1, m) {
                    A[i][j] = fl;
                }
                id += x;
            }
        }
        else {
            int id = 1, fl = 0;
            for (auto x : tem) {
                fl = 1 - fl;
                rep(i, id, id + x - 1) rep(j, 1, n) {
                    A[j][i] = fl;
                }
                id += x;
            }
        }

        rep(i, 1, n) {
            rep(j, 1, m) cout << A[i][j];
            cout << endl;
        }

    }
    return 0;
}

詳細信息

Test #1:

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

input:

2
2 3
1 1

output:

Yes
101
101
No

result:

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