結果

問題 No.2373 wa, wo, n
ユーザー lam6er
提出日時 2025-03-20 18:47:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 76,148 KB
最終ジャッジ日時 2025-03-20 18:47:58
合計ジャッジ時間 3,234 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input().strip()

state0 = True
state1 = False

for i in range(n):
    current_char = s[i]
    new_state0 = False
    new_state1 = False
    
    if state0:
        # Check if can take 'n' here
        if current_char == 'n' or current_char == '?':
            new_state0 = True
        # Check if can start a 'w' followed by 'a'/'o'
        if current_char == 'w' or current_char == '?':
            if i < n - 1:
                new_state1 = True
    
    if state1:
        # Check if current_char can be 'a' or 'o'
        if current_char in {'a', 'o', '?'}:
            new_state0 = True
    
    state0, state1 = new_state0, new_state1
    
    if not (state0 or state1):
        break

print("Yes" if state0 else "No")
0