結果

問題 No.2373 wa, wo, n
ユーザー ryusukeryusuke
提出日時 2023-07-09 17:45:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,086 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 30,860 KB
最終ジャッジ日時 2023-09-30 21:13:34
合計ジャッジ時間 4,789 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,688 KB
testcase_01 AC 18 ms
8,708 KB
testcase_02 AC 18 ms
8,556 KB
testcase_03 AC 18 ms
8,552 KB
testcase_04 AC 18 ms
8,720 KB
testcase_05 AC 18 ms
8,552 KB
testcase_06 AC 18 ms
8,612 KB
testcase_07 AC 18 ms
8,596 KB
testcase_08 AC 18 ms
8,712 KB
testcase_09 AC 17 ms
8,552 KB
testcase_10 AC 18 ms
8,692 KB
testcase_11 AC 18 ms
8,636 KB
testcase_12 AC 18 ms
8,560 KB
testcase_13 AC 18 ms
8,652 KB
testcase_14 AC 121 ms
26,404 KB
testcase_15 AC 35 ms
11,528 KB
testcase_16 AC 130 ms
28,120 KB
testcase_17 AC 48 ms
13,920 KB
testcase_18 AC 21 ms
9,064 KB
testcase_19 AC 56 ms
15,844 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 149 ms
28,848 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 18 ms
8,740 KB
testcase_27 AC 18 ms
8,532 KB
testcase_28 WA -
testcase_29 AC 18 ms
8,564 KB
testcase_30 AC 18 ms
8,540 KB
testcase_31 AC 18 ms
8,564 KB
testcase_32 AC 157 ms
30,860 KB
testcase_33 WA -
testcase_34 AC 172 ms
30,680 KB
testcase_35 AC 110 ms
30,676 KB
testcase_36 AC 148 ms
30,768 KB
testcase_37 AC 144 ms
30,676 KB
testcase_38 AC 150 ms
30,760 KB
testcase_39 AC 155 ms
30,760 KB
testcase_40 AC 152 ms
30,788 KB
testcase_41 AC 152 ms
30,668 KB
testcase_42 AC 163 ms
30,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# verification-helper: PROBLEM https://yukicoder.me/problems/no/2373

from collections import deque

def main() -> None:
    n = int(input())
    s = list(input())
    dp = [[False] * 4 for _ in range(n + 1)]
    # 0 := w, 1 := a, 2 := o, 3 := n, 4 := ?
    if s[0] == "w":
        dp[1][0] = True
    elif s[0] == "n":
        dp[1][3] = True
    elif s[0] == "?":
        dp[1][0] = True
        dp[1][3] = True
    else:
        exit(print("No"))
    
    for i in range(2, n + 1):
        if s[i - 1] == "a":
            dp[i][1] |= dp[i - 1][0]
        elif s[i - 1] == "o":
            dp[i][2] |= dp[i - 1][0]
        elif s[i - 1] == "w":
            dp[i][0] = True
        elif s[i - 1] == "n":
            dp[i][3] = True
        elif s[i - 1] == "?":
            if dp[i - 1][0]:
                dp[i][1] = True
                dp[i][2] = True
            else:
                dp[i][3] = True
        else:
            exit(print("No"))

    #print(*dp, sep="\n")
    print("Yes") if dp[n][1] or dp[n][2] or dp[n][3] else print("No")


if __name__ == "__main__":
    main()
0