結果
| 問題 |
No.2373 wa, wo, n
|
| コンテスト | |
| ユーザー |
poyon
|
| 提出日時 | 2023-06-23 18:52:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 155 ms / 2,000 ms |
| コード長 | 697 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 82,340 KB |
| 実行使用メモリ | 77,952 KB |
| 最終ジャッジ日時 | 2024-07-02 11:27:36 |
| 合計ジャッジ時間 | 4,026 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 39 |
ソースコード
import sys
input = sys.stdin.readline
def main():
N = int(input())
S = input().rstrip()
def match(S, P):
assert(len(S) == len(P))
for s, p in zip(S, P):
if (s == p or s == '?'): continue
return False
return True
patterns = ("wa", "wo", "n")
# dp[i] := S[0,i) が wawon 文字列であるか否か
dp = [False] * (N + 1)
dp[0] = True
for i in range(N):
if not dp[i]: continue
for p in patterns:
n = len(p)
if (i + n <= N and match(S[i:i + n], p)):
dp[i + n] = True
ans = "Yes" if dp[N] else "No"
print(ans)
if __name__ == "__main__":
main()
poyon