結果
| 問題 | No.2373 wa, wo, n | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-07-21 11:27:05 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 841 ms / 2,000 ms | 
| コード長 | 332 bytes | 
| コンパイル時間 | 152 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 12,768 KB | 
| 最終ジャッジ日時 | 2024-09-21 13:37:20 | 
| 合計ジャッジ時間 | 9,426 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 39 | 
ソースコード
n = int(input())
s = input()
def match(s, p):
	for s, p in zip(s, p):
		if s != p and s != '?':
			return False
	return True
dp = [False] * (n + 1)
dp[0] = True
for i in range(n):
	if dp[i]:
		for p in ["wa", "wo", "n"]:
			if i + len(p) <= n and match(s[i: i + len(p)], p):
				dp[i + len(p)] = True
print("Yes" if dp[n] else "No")
            
            
            
        