結果
問題 | No.2165 Let's Play Nim! |
ユーザー | Shirotsume |
提出日時 | 2022-12-16 02:32:31 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,746 bytes |
コンパイル時間 | 199 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 89,928 KB |
平均クエリ数 | 2.00 |
最終ジャッジ日時 | 2024-11-15 06:36:59 |
合計ジャッジ時間 | 6,380 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | WA | - |
testcase_11 | RE | - |
testcase_12 | WA | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | WA | - |
testcase_17 | RE | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 62 ms
71,008 KB |
testcase_31 | AC | 63 ms
71,252 KB |
testcase_32 | WA | - |
evil_2_big_1.txt | RE | - |
evil_2_big_2.txt | WA | - |
evil_2_big_3.txt | WA | - |
evil_big_1.txt | RE | - |
evil_big_2.txt | RE | - |
evil_big_3.txt | RE | - |
ソースコード
import sys from collections import defaultdict, deque, Counter sys.setrecursionlimit(5 * 10 ** 5) from pypyjit import set_param set_param('max_unroll_recursion=-1') input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n = ii() a = li() class segtree(): n=1 size=1 log=2 d=[0] op=None e=10**15 def __init__(self,V,OP,E): self.n=len(V) self.op=OP self.e=E self.log=(self.n-1).bit_length() self.size=1<<self.log self.d=[E for i in range(2*self.size)] for i in range(self.n): self.d[self.size+i]=V[i] for i in range(self.size-1,0,-1): self.update(i) def set(self,p,x): assert 0<=p and p<self.n p+=self.size self.d[p]=x for i in range(1,self.log+1): self.update(p>>i) def get(self,p): assert 0<=p and p<self.n return self.d[p+self.size] def __setitem__(self, p, x): self.set(p, x) def __getitem__(self, p): if isinstance(p, int): return self.get(p) else: return self.prod(p.start, p.stop) def prod(self,l,r): assert 0<=l and l<=r and r<=self.n sml=self.e smr=self.e l+=self.size r+=self.size while(l<r): if (l&1): sml=self.op(sml,self.d[l]) l+=1 if (r&1): smr=self.op(self.d[r-1],smr) r-=1 l>>=1 r>>=1 return self.op(sml,smr) def all_prod(self): return self.d[1] def update(self,k): self.d[k]=self.op(self.d[2*k],self.d[2*k+1]) def __str__(self): return str([self.get(i) for i in range(self.n)]) xor = 0 di = {} for i in range(n): if a[i] not in di: di[a[i]] = set([i]) di[a[i]].add(i) for v in a: xor ^= v a = segtree(a, max, -inf) def oppo(): global xor i, k = mi() i -= 1 if a[i] not in di: while True: pass di[a[i]].discard(i) xor ^= a[i] a[i] -= k xor ^= a[i] if a[i] not in di: di[a[i]] = set([i]) di[a[i]].add(i) def me(): global xor if a.all_prod() not in di: while True: pass i = di[a.all_prod()].pop() k = xor xor = 0 a[i] -= k print(i + 1, k, flush=True) if a[i] not in di: di[a[i]] = set([i]) di[a[i]].add(i) if xor == 0: print(0, flush=True) oppo() else: print(1, flush=True) while True: me() r = ii() if r == -1: exit() oppo() r = ii() if r == -1: exit()