結果

問題 No.2373 wa, wo, n
ユーザー NP
提出日時 2023-07-07 21:40:59
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 419 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 82,028 KB
実行使用メモリ 385,184 KB
最終ジャッジ日時 2024-07-21 17:26:59
合計ジャッジ時間 5,790 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 RE * 4 TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()

def is_wawon(s):
    if not s:
        return True
    if s[:2] == 'wa' or s[:2] == 'wo':
        return is_wawon(s[2:])
    if s[0] == 'n':
        return is_wawon(s[1:])
    return False

def solve(S):
    if '?' not in S:
        return is_wawon(S)
    for c in 'wan':
        if solve(S.replace('?', c, 1)):
            return True
    return False

print('Yes' if solve(S) else 'No')
0