結果
問題 | No.2165 Let's Play Nim! |
ユーザー | Shirotsume |
提出日時 | 2022-12-16 02:33:25 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,681 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,376 KB |
実行使用メモリ | 90,684 KB |
平均クエリ数 | 2.03 |
最終ジャッジ日時 | 2024-04-27 06:50:22 |
合計ジャッジ時間 | 6,281 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
71,364 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
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 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 64 ms
71,628 KB |
testcase_31 | AC | 64 ms
71,792 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 | WA | - |
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 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 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() r = ii() if r == -1: exit() else: print(1, flush=True) while True: me() r = ii() if r == -1: exit() oppo() r = ii() if r == -1: exit()