結果

問題 No.2373 wa, wo, n
ユーザー dango
提出日時 2023-07-07 21:27:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 617 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 73,116 KB
最終ジャッジ日時 2024-07-21 17:08:21
合計ジャッジ時間 2,893 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def is_wawon_string(S):
    i = 0
    while i < len(S):
        if S[i] == "w":
            if i + 1 < len(S) and S[i + 1] in ["a", "o"]:
                i += 2
            else:
                return False
        elif S[i] == "n":
            i += 1
        else:
            return False
    return True

if "?" not in S:
    if is_wawon_string(S):
        print("Yes")
    else:
        print("No")
else:
    for c in ["a", "n", "o", "w"]:
        new_S = S.replace("?", c)
        if is_wawon_string(new_S):
            print("Yes")
            break
    else:
        print("No")
0