結果
問題 | No.1245 ANDORゲーム(calc) |
ユーザー |
|
提出日時 | 2020-10-02 22:30:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 274 ms / 2,000 ms |
コード長 | 1,078 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 82,068 KB |
実行使用メモリ | 100,600 KB |
最終ジャッジ日時 | 2024-07-17 22:03:00 |
合計ジャッジ時間 | 6,922 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
n,q=map(int,input().split()) a=list(map(int,input().split())) s=input() t=list(map(int,input().split())) l=max(max(a),max(t)).bit_length() points=[[0]*2 for _ in range(l)] for i in range(l-1,-1,-1): k=2**i tmp1=0 tmp2=1 for j in range(n): if s[j]=='0': #bit on if a[j]&k: continue #bit off else: if tmp1==1: tmp1=0 points[i][0]+=k if tmp2==1: tmp2=0 points[i][1]+=k elif s[j]=='1': #bit on if a[j]&k: if tmp1==0: tmp1=1 points[i][0]+=k if tmp2==0: tmp2=1 points[i][1]+=k #bit off else: continue for val in t: tmp=0 for i in range(l-1,-1,-1): #bit on if val&(2**i): tmp+=points[i][1] #bit off else: tmp+=points[i][0] print(tmp)