結果

問題 No.2702 Nand Nor Matrix
ユーザー sotanishysotanishy
提出日時 2024-03-29 22:56:54
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,733 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 131,628 KB
最終ジャッジ日時 2024-03-29 22:57:12
合計ジャッジ時間 15,679 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 192 ms
121,176 KB
testcase_02 AC 203 ms
121,072 KB
testcase_03 AC 184 ms
121,172 KB
testcase_04 AC 192 ms
120,952 KB
testcase_05 AC 184 ms
121,004 KB
testcase_06 AC 193 ms
121,172 KB
testcase_07 AC 189 ms
121,204 KB
testcase_08 AC 210 ms
121,184 KB
testcase_09 AC 193 ms
121,220 KB
testcase_10 AC 190 ms
121,068 KB
testcase_11 AC 189 ms
121,260 KB
testcase_12 AC 193 ms
121,308 KB
testcase_13 AC 212 ms
121,344 KB
testcase_14 AC 189 ms
121,184 KB
testcase_15 AC 182 ms
121,184 KB
testcase_16 AC 203 ms
111,924 KB
testcase_17 AC 128 ms
99,664 KB
testcase_18 AC 167 ms
103,184 KB
testcase_19 AC 259 ms
124,292 KB
testcase_20 AC 144 ms
96,600 KB
testcase_21 AC 150 ms
96,000 KB
testcase_22 AC 130 ms
90,484 KB
testcase_23 AC 211 ms
118,540 KB
testcase_24 AC 212 ms
108,712 KB
testcase_25 AC 133 ms
93,820 KB
testcase_26 AC 174 ms
99,276 KB
testcase_27 AC 246 ms
127,684 KB
testcase_28 AC 208 ms
115,100 KB
testcase_29 AC 98 ms
84,812 KB
testcase_30 AC 260 ms
124,368 KB
testcase_31 AC 209 ms
121,004 KB
testcase_32 AC 82 ms
81,440 KB
testcase_33 AC 116 ms
94,096 KB
testcase_34 AC 208 ms
114,884 KB
testcase_35 AC 234 ms
119,720 KB
testcase_36 AC 275 ms
131,112 KB
testcase_37 AC 286 ms
130,220 KB
testcase_38 AC 280 ms
130,348 KB
testcase_39 AC 263 ms
131,116 KB
testcase_40 AC 278 ms
130,220 KB
testcase_41 AC 278 ms
130,348 KB
testcase_42 AC 311 ms
130,220 KB
testcase_43 AC 282 ms
130,348 KB
testcase_44 AC 290 ms
131,624 KB
testcase_45 AC 289 ms
131,500 KB
testcase_46 AC 310 ms
131,628 KB
testcase_47 AC 287 ms
130,348 KB
testcase_48 AC 285 ms
130,220 KB
testcase_49 AC 284 ms
130,220 KB
testcase_50 AC 298 ms
130,092 KB
testcase_51 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline

T = 20


def naive(N, A, B, qs):
    X = [[[0] * N for _ in range(N)] for _ in range(T)]
    for i in range(N):
        X[0][0][i] = A[i]
    for i in range(1, N):
        X[0][i][0] = B[i]

    # print(*["".join(map(str, row)) for row in X], sep="\n")
    # print()

    for t in range(1, T):
        for i in range(N):
            for j in range(N):
                if i == 0 or j == 0:
                    X[t][i][j] = X[t - 1][i][j]
                else:
                    X[t][i][j] = (
                        0
                        if X[t - 1][i][j] + X[t - 1][i - 1][j] + X[t - 1][i][j - 1] >= 2
                        else 1
                    )
        # print(*["".join(map(str, row)) for row in X], sep="\n")
        # print()

    return [X[t][r][c] for t, r, c in qs]


def solve(N, A, B, qs):
    row = [-1] * N
    row[0] = B[1]
    for i in range(1, N):
        if row[i - 1] == A[i]:
            row[i] = A[i] ^ 1
        else:
            break

    col = [-1] * N
    col[0] = A[1]
    for i in range(1, N):
        if col[i - 1] == B[i]:
            col[i] = B[i] ^ 1
        else:
            break

    ans = []
    for t, r, c in qs:
        x = -1
        if r == 0:
            x = A[c]
        elif c == 0:
            x = B[r]
        elif col[r] == -1 or row[c] == -1 or r + c > t + 1:
            x = t % 2
        else:
            x = A[c] ^ B[r] ^ A[1] ^ 1
        ans.append(x)
    return ans


N = int(input())
A = list(map(int, input().split()))
B = [A[0]] + [int(input()) for _ in range(N - 1)]
Q = int(input())
qs = []
for _ in range(Q):
    t, r, c = map(int, input().split())
    qs.append((t, r - 1, c - 1))
print(*solve(N, A, B, qs), sep="\n")
0