結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,660 KB
testcase_01 AC 19 ms
8,564 KB
testcase_02 AC 19 ms
8,660 KB
testcase_03 AC 19 ms
8,648 KB
testcase_04 AC 18 ms
8,656 KB
testcase_05 AC 18 ms
8,568 KB
testcase_06 AC 17 ms
8,664 KB
testcase_07 AC 17 ms
8,656 KB
testcase_08 AC 18 ms
8,620 KB
testcase_09 AC 18 ms
8,568 KB
testcase_10 AC 17 ms
8,656 KB
testcase_11 AC 17 ms
8,536 KB
testcase_12 AC 18 ms
8,620 KB
testcase_13 AC 18 ms
8,628 KB
testcase_14 AC 122 ms
26,316 KB
testcase_15 AC 35 ms
11,460 KB
testcase_16 AC 131 ms
28,128 KB
testcase_17 AC 47 ms
13,856 KB
testcase_18 AC 21 ms
9,140 KB
testcase_19 AC 57 ms
15,808 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 150 ms
28,920 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 18 ms
8,704 KB
testcase_27 AC 19 ms
8,576 KB
testcase_28 AC 19 ms
8,684 KB
testcase_29 AC 18 ms
8,660 KB
testcase_30 AC 18 ms
8,656 KB
testcase_31 AC 18 ms
8,616 KB
testcase_32 AC 159 ms
30,684 KB
testcase_33 WA -
testcase_34 AC 178 ms
30,744 KB
testcase_35 AC 108 ms
30,812 KB
testcase_36 AC 151 ms
30,728 KB
testcase_37 AC 144 ms
30,728 KB
testcase_38 AC 148 ms
30,740 KB
testcase_39 AC 155 ms
30,728 KB
testcase_40 AC 153 ms
30,700 KB
testcase_41 AC 156 ms
30,672 KB
testcase_42 AC 164 ms
30,684 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
                if i != n:
                    dp[i][0] = 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