結果

問題 No.2283 Prohibit Three Consecutive
ユーザー gr1msl3y
提出日時 2023-04-30 16:25:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 449 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,104 KB
実行使用メモリ 79,052 KB
最終ジャッジ日時 2024-11-19 07:04:48
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 WA * 5
権限があれば一括ダウンロードができます

ソースコード

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