結果

問題 No.74 貯金箱の退屈
ユーザー matsu7874matsu7874
提出日時 2014-11-21 00:05:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 12,632 KB
最終ジャッジ日時 2023-08-30 21:57:20
合計ジャッジ時間 6,898 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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