結果

問題 No.2373 wa, wo, n
ユーザー ryusukeryusuke
提出日時 2023-07-09 17:56:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 1,569 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 30,868 KB
最終ジャッジ日時 2023-09-30 21:25:50
合計ジャッジ時間 4,974 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,824 KB
testcase_01 AC 18 ms
8,592 KB
testcase_02 AC 18 ms
8,740 KB
testcase_03 AC 18 ms
8,596 KB
testcase_04 AC 20 ms
8,712 KB
testcase_05 AC 20 ms
8,772 KB
testcase_06 AC 19 ms
8,632 KB
testcase_07 AC 18 ms
8,680 KB
testcase_08 AC 19 ms
8,668 KB
testcase_09 AC 19 ms
8,668 KB
testcase_10 AC 18 ms
8,672 KB
testcase_11 AC 18 ms
8,660 KB
testcase_12 AC 19 ms
8,700 KB
testcase_13 AC 18 ms
8,672 KB
testcase_14 AC 154 ms
26,528 KB
testcase_15 AC 41 ms
11,380 KB
testcase_16 AC 165 ms
28,212 KB
testcase_17 AC 57 ms
13,996 KB
testcase_18 AC 22 ms
9,296 KB
testcase_19 AC 54 ms
15,876 KB
testcase_20 AC 110 ms
25,824 KB
testcase_21 AC 53 ms
15,668 KB
testcase_22 AC 82 ms
20,276 KB
testcase_23 AC 141 ms
28,916 KB
testcase_24 AC 18 ms
8,668 KB
testcase_25 AC 19 ms
8,832 KB
testcase_26 AC 18 ms
8,688 KB
testcase_27 AC 18 ms
8,844 KB
testcase_28 AC 18 ms
8,600 KB
testcase_29 AC 18 ms
8,640 KB
testcase_30 AC 19 ms
8,812 KB
testcase_31 AC 19 ms
8,784 KB
testcase_32 AC 198 ms
30,828 KB
testcase_33 AC 150 ms
30,752 KB
testcase_34 AC 280 ms
30,740 KB
testcase_35 AC 150 ms
30,868 KB
testcase_36 AC 185 ms
30,760 KB
testcase_37 AC 185 ms
30,744 KB
testcase_38 AC 191 ms
30,756 KB
testcase_39 AC 184 ms
30,744 KB
testcase_40 AC 190 ms
30,800 KB
testcase_41 AC 189 ms
30,748 KB
testcase_42 AC 201 ms
30,868 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
    if s[0] == "w":
        dp[1][0] = True
    if s[0] == "n":
        dp[1][3] = True
    if s[0] == "?":
        dp[1][0] = True
        dp[1][3] = True
    
    for i in range(2, n + 1):
        if dp[i - 1][0]:
            if s[i - 1] == "a":
                dp[i][1] = True
            if s[i - 1] == "o":
                dp[i][2] = True
            if s[i - 1] == "?":
                dp[i][1] = True
                dp[i][2] = True
        if dp[i - 1][1]:
            if s[i - 1] == "w":
                dp[i][0] = True
            if s[i - 1] == "n":
                dp[i][3] = True
            if s[i - 1] == "?":
                dp[i][0] = True
                dp[i][3] = True
        if dp[i - 1][2]:
            if s[i - 1] == "w":
                dp[i][0] = True
            if s[i - 1] == "n":
                dp[i][3] = True
            if s[i - 1] == "?":
                dp[i][0] = True
                dp[i][3] = True
        if dp[i - 1][3]:
            if s[i - 1] == "w":
                dp[i][0] = True
            if s[i - 1] == "n":
                dp[i][3] = True
            if s[i - 1] == "?":
                dp[i][0] = True
                dp[i][3] = True

    #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