結果

問題 No.2702 Nand Nor Matrix
ユーザー hirayuu_yc
提出日時 2024-02-06 12:22:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 951 bytes
コンパイル時間 412 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 103,364 KB
最終ジャッジ日時 2024-09-28 12:12:56
合計ジャッジ時間 12,891 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit((1<<19)-1)
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
input=sys.stdin.buffer.readline

N=int(input())
A=list(map(int,input().split()))
A.append(A[-1])
B=[A[0]]+[int(input()) for i in range(N-1)]
B.append(B[-1])
col=0
for i in range(1,N):
    if A[i]==A[i+1]:
        col=i
        break
row=0
for i in range(1,N):
    if B[i]==B[i+1]:
        row=i
        break
if A[1]!=B[1]:
    row=0
    col=0
change=0
if A[1]==B[1]==0:
    A=[i^1 for i in A]
    B=[i^1 for i in B]
    change=1
Q=int(input())
for i in range(Q):
    T,R,C=map(int,input().split())
    R-=1
    C-=1
    T-=change
    if R==0:
        print(A[C]^change)
        continue
    if C==0:
        print(B[R]^change)
        continue
    if T<=0:
        print((T&1)^change)
        continue
    if R<=row and C<=col and R+C-1<=T:
        print(((R+C)&1)^change)
        continue
    else:
        print((T&1)^change)
        continue
0