結果
問題 | No.2702 Nand Nor Matrix |
ユーザー | sotanishy |
提出日時 | 2024-03-29 22:58:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 285 ms / 2,000 ms |
コード長 | 1,780 bytes |
コンパイル時間 | 302 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 132,356 KB |
最終ジャッジ日時 | 2024-09-30 16:43:45 |
合計ジャッジ時間 | 16,895 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,224 KB |
testcase_01 | AC | 228 ms
121,392 KB |
testcase_02 | AC | 187 ms
121,744 KB |
testcase_03 | AC | 181 ms
121,648 KB |
testcase_04 | AC | 196 ms
121,256 KB |
testcase_05 | AC | 192 ms
121,776 KB |
testcase_06 | AC | 205 ms
121,380 KB |
testcase_07 | AC | 195 ms
121,740 KB |
testcase_08 | AC | 199 ms
121,724 KB |
testcase_09 | AC | 193 ms
122,004 KB |
testcase_10 | AC | 193 ms
121,732 KB |
testcase_11 | AC | 197 ms
121,548 KB |
testcase_12 | AC | 192 ms
121,848 KB |
testcase_13 | AC | 202 ms
121,632 KB |
testcase_14 | AC | 195 ms
121,724 KB |
testcase_15 | AC | 193 ms
121,464 KB |
testcase_16 | AC | 203 ms
112,364 KB |
testcase_17 | AC | 131 ms
99,712 KB |
testcase_18 | AC | 173 ms
103,952 KB |
testcase_19 | AC | 240 ms
124,696 KB |
testcase_20 | AC | 147 ms
96,768 KB |
testcase_21 | AC | 158 ms
96,536 KB |
testcase_22 | AC | 130 ms
90,964 KB |
testcase_23 | AC | 225 ms
119,068 KB |
testcase_24 | AC | 210 ms
109,432 KB |
testcase_25 | AC | 142 ms
94,304 KB |
testcase_26 | AC | 159 ms
100,268 KB |
testcase_27 | AC | 239 ms
128,096 KB |
testcase_28 | AC | 209 ms
115,408 KB |
testcase_29 | AC | 100 ms
84,992 KB |
testcase_30 | AC | 260 ms
124,972 KB |
testcase_31 | AC | 216 ms
121,796 KB |
testcase_32 | AC | 87 ms
82,392 KB |
testcase_33 | AC | 124 ms
94,208 KB |
testcase_34 | AC | 217 ms
115,680 KB |
testcase_35 | AC | 235 ms
120,412 KB |
testcase_36 | AC | 271 ms
131,724 KB |
testcase_37 | AC | 274 ms
130,948 KB |
testcase_38 | AC | 279 ms
130,688 KB |
testcase_39 | AC | 265 ms
131,716 KB |
testcase_40 | AC | 274 ms
130,820 KB |
testcase_41 | AC | 280 ms
131,204 KB |
testcase_42 | AC | 270 ms
130,820 KB |
testcase_43 | AC | 273 ms
130,884 KB |
testcase_44 | AC | 285 ms
132,356 KB |
testcase_45 | AC | 284 ms
132,100 KB |
testcase_46 | AC | 280 ms
131,972 KB |
testcase_47 | AC | 276 ms
130,824 KB |
testcase_48 | AC | 281 ms
130,692 KB |
testcase_49 | AC | 273 ms
132,352 KB |
testcase_50 | AC | 266 ms
130,700 KB |
testcase_51 | AC | 173 ms
108,808 KB |
ソースコード
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): if N == 1: return [A[0]] * len(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")