結果
問題 | No.2283 Prohibit Three Consecutive |
ユーザー |
![]() |
提出日時 | 2023-04-28 22:02:20 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 537 bytes |
コンパイル時間 | 127 ms |
コンパイル使用メモリ | 82,584 KB |
実行使用メモリ | 81,028 KB |
最終ジャッジ日時 | 2024-11-17 20:59:51 |
合計ジャッジ時間 | 1,995 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 WA * 5 |
ソースコード
def solve(): n=int(input()) s=list(input()) inf=10**9 for i in range(3): if s[i]!='1' and s[i-1]!='0': t=s[i:]+s[:i] dp=[1,inf] for j in range(1,n): ndp=[inf,inf] if t[j]=='0' or t[j]=='?': ndp[0]=dp[0]+1 if dp[1]<3: ndp[0]=1 if t[j]=='1' or t[j]=='?': ndp[1]=dp[1]+1 if dp[0]<3: ndp[1]=1 dp=ndp if dp[1]<3: print('Yes') return print('No') for _ in range(int(input())): solve()