結果

問題 No.2283 Prohibit Three Consecutive
ユーザー gr1msl3ygr1msl3y
提出日時 2023-04-30 16:25:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 449 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 79,104 KB
最終ジャッジ日時 2024-04-29 22:27:25
合計ジャッジ時間 4,051 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,224 KB
testcase_01 AC 44 ms
60,160 KB
testcase_02 AC 43 ms
60,160 KB
testcase_03 AC 336 ms
77,260 KB
testcase_04 AC 310 ms
77,184 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 170 ms
75,904 KB
testcase_09 AC 175 ms
76,416 KB
testcase_10 AC 181 ms
76,160 KB
testcase_11 AC 183 ms
76,160 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(S):
	S+=S
	dp=[0]*4
	for i in range(4):
		if S[0] in {'?',str(i//2)}:
			if S[1] in {'?',str(i%2)}:
				dp[i]=1
	for s in S[2:]:
		ndp=[0]*4
		for i in range(4):
			for j in range(2):
				if s not in {'?',str(j)}: continue
				k=(i<<1)|j
				if k not in {0,7}:
					ndp[k&3]|=dp[i]
		dp=ndp
	return 'Yes' if sum(dp) else 'No'

T=int(input())
ans=[]
for _ in range(T):
	_=int(input())
	S=input()
	ans.append(solve(S))

print(*ans,sep='\n')
0