結果

問題 No.2702 Nand Nor Matrix
ユーザー MagentorMagentor
提出日時 2024-03-11 22:02:43
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 380 ms / 2,000 ms
コード長 1,608 bytes
コンパイル時間 1,205 ms
コンパイル使用メモリ 89,284 KB
実行使用メモリ 9,240 KB
最終ジャッジ日時 2024-03-11 22:03:05
合計ジャッジ時間 21,047 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 301 ms
6,548 KB
testcase_02 AC 298 ms
6,548 KB
testcase_03 AC 309 ms
6,548 KB
testcase_04 AC 302 ms
6,676 KB
testcase_05 AC 303 ms
6,676 KB
testcase_06 AC 300 ms
6,676 KB
testcase_07 AC 310 ms
6,676 KB
testcase_08 AC 301 ms
6,676 KB
testcase_09 AC 302 ms
6,676 KB
testcase_10 AC 302 ms
6,676 KB
testcase_11 AC 327 ms
6,676 KB
testcase_12 AC 302 ms
6,676 KB
testcase_13 AC 308 ms
6,676 KB
testcase_14 AC 301 ms
6,676 KB
testcase_15 AC 300 ms
6,676 KB
testcase_16 AC 232 ms
6,676 KB
testcase_17 AC 72 ms
8,128 KB
testcase_18 AC 185 ms
6,676 KB
testcase_19 AC 329 ms
6,676 KB
testcase_20 AC 78 ms
6,764 KB
testcase_21 AC 143 ms
6,676 KB
testcase_22 AC 100 ms
6,676 KB
testcase_23 AC 302 ms
6,676 KB
testcase_24 AC 239 ms
8,664 KB
testcase_25 AC 118 ms
6,676 KB
testcase_26 AC 151 ms
6,676 KB
testcase_27 AC 336 ms
6,676 KB
testcase_28 AC 274 ms
6,676 KB
testcase_29 AC 29 ms
6,676 KB
testcase_30 AC 306 ms
8,744 KB
testcase_31 AC 325 ms
6,676 KB
testcase_32 AC 13 ms
6,676 KB
testcase_33 AC 54 ms
6,676 KB
testcase_34 AC 271 ms
6,676 KB
testcase_35 AC 319 ms
6,676 KB
testcase_36 AC 358 ms
9,240 KB
testcase_37 AC 354 ms
9,240 KB
testcase_38 AC 379 ms
9,240 KB
testcase_39 AC 355 ms
9,240 KB
testcase_40 AC 352 ms
9,240 KB
testcase_41 AC 380 ms
9,240 KB
testcase_42 AC 355 ms
9,240 KB
testcase_43 AC 354 ms
9,240 KB
testcase_44 AC 380 ms
9,240 KB
testcase_45 AC 351 ms
9,240 KB
testcase_46 AC 353 ms
9,240 KB
testcase_47 AC 380 ms
9,240 KB
testcase_48 AC 352 ms
9,240 KB
testcase_49 AC 358 ms
9,240 KB
testcase_50 AC 354 ms
9,240 KB
testcase_51 AC 321 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];
    A.push_back(A.back());
    B[0] = A[0];
    for (int i = 1; i < N; ++i)
        cin >> B[i];
    B.push_back(B.back());
    int col = 0;
    for (int i = 1; i < N; ++i) {
        if (A[i] == A[i + 1]) {
            col = i;
            break;
        }
    }
    int row = 0;
    for (int i = 1; i < N; ++i) {
        if (B[i] == B[i + 1]) {
            row = i;
            break;
        }
    }
    if (A[1] != B[1]) {
        row = 0;
        col = 0;
    }
    int change = 0;
    if (A[1] == B[1] && A[1] == 0) {
        for (int i = 0; i <= N; ++i) {
            A[i] ^= 1;
            B[i] ^= 1;
        }
        change = 1;
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int T, R, C;
        cin >> T >> R >> C;
        --R;
        --C;
        T -= change;
        if (R == 0) {
            cout << (A[C] ^ change) << endl;
            continue;
        }
        if (C == 0) {
            cout << (B[R] ^ change) << endl;
            continue;
        }
        if (T <= 0) {
            cout << ((T & 1) ^ change) << endl;
            continue;
        }
        if (R <= row && C <= col && R + C - 1 <= T) {
            cout << (((R + C) & 1) ^ change) << endl;
            continue;
        } else {
            cout << ((T & 1) ^ change) << endl;
            continue;
        }
    }
    return 0;
}
0