結果

問題 No.2702 Nand Nor Matrix
ユーザー 鴨志田卓
提出日時 2024-04-09 01:14:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 790 bytes
コンパイル時間 1,804 ms
コンパイル使用メモリ 193,404 KB
最終ジャッジ日時 2025-02-20 23:16:11
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int N = 2e5 + 10;

int n, w, h, a[N], b[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
    }

    for(int i = 2; i <= n; i ++) {
        cin >> b[i];
    }

    if(a[2] == b[2]) {
        for(w = 2; w < n && a[w] != a[w + 1]; w ++);
        for(h = 2; h < n && b[h] != b[h + 1]; h ++);
    }

    int q;
    cin >> q;
    for(int i = 1; i <= q; i ++) {
        long long t;
        int x, y;
        cin >> t >> x >> y;
        if(x == 1) cout << a[y] << "\n";
        else if(y == 1) cout << b[x] << "\n";
        else if(x <= h && y <= w && t >= x + y - 3) cout << ((a[2] ^ (x + y - 3)) & 1) << "\n";
        else cout << (t & 1) << "\n";
    }
}
0