結果

問題 No.2373 wa, wo, n
ユーザー prd_xxx
提出日時 2023-07-07 22:17:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 82,692 KB
実行使用メモリ 76,020 KB
最終ジャッジ日時 2024-07-21 18:22:27
合計ジャッジ時間 3,428 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 38 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
for c in S:
    if c not in 'waon?':
        exit(print('No'))

T = S.replace('n','').replace('wa','').replace('wo','')
if T=='':
    exit(print('Yes'))

T = T.replace('o','a')
assert all(c in 'wa?' for c in T)

if T[0]=='a' or T[-1]=='w':
    exit(print('No'))

buf = ''
for c in T:
    if c == 'w':
        if buf=='w' or buf=='a':
            exit(print('No'))
        buf = 'w'
    elif c == 'a':
        if buf=='a' or buf=='':
            exit(print('No'))
        buf = ''
    else:
        assert c=='?'
        if buf=='w':
            buf = ''
        elif buf=='a':
            assert False
        else:
            buf = '?'
if buf=='?' or buf == '':
    print('Yes')
else:
    print('No')
0