結果
| 問題 |
No.1863 Xor Sum 2...?
|
| コンテスト | |
| ユーザー |
AEn
|
| 提出日時 | 2022-09-02 16:51:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 738 bytes |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 103,424 KB |
| 最終ジャッジ日時 | 2024-11-15 21:31:17 |
| 合計ジャッジ時間 | 5,208 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 23 |
ソースコード
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
def syaku(a, b):
l, r = a, a
sm1, sm2 = 0, 0
res = 0
while l<b:
while r<b and sm1+A[r]==sm2^A[r]:
sm1 += A[r]
sm2 ^= A[r]
r += 1
res += r-l
sm1 -= A[l]
sm2 ^= A[l]
l += 1
if l>r:
r = l
return res
s = -1
cnt = 0
ans = 0
for i in range(N):
if B[i] == 0:
if s==-1:
s = i
cnt = 1
else:
cnt += 1
else:
if cnt>0:
ans += syaku(s, s+cnt)
cnt = 0
s = -1
else:
continue
if cnt>0:
ans += syaku(s, s+cnt)
print(ans)
AEn