結果

問題 No.74 貯金箱の退屈
ユーザー matsu7874
提出日時 2014-11-21 00:05:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 24,136 KB
最終ジャッジ日時 2025-01-02 19:31:43
合計ジャッジ時間 175,794 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 1 TLE * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

N = int(input())
D = list(map(int, input().split(' ')))
W_ = list(map(int, input().split(' ')))

W = W_
turned = [0]*N

def turn(n):
	if W[n] == 1:
		W[n] = 0
	else:
		W[n] = 1

def select(n):
	turn((n+D[n])%N)
	turn((n-D[n])%N)
	if ((n+D[n])%N) == ((n-D[n])%N):
		turn((n+D[n])%N)

T = [0,1]
for x in itertools.product(T,repeat=N):
	W = W_
	for i in range(0,N):
		if x[i] == 1:
			select(i)
	if 0 not in W:
		print("YES")
		exit()
print("NO")
0