結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 WA -
testcase_03 AC 18 ms
8,552 KB
testcase_04 AC 19 ms
8,644 KB
testcase_05 AC 18 ms
8,560 KB
testcase_06 AC 18 ms
8,724 KB
testcase_07 AC 18 ms
8,592 KB
testcase_08 AC 18 ms
8,588 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 18 ms
8,588 KB
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 33 ms
11,468 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 54 ms
15,880 KB
testcase_20 AC 113 ms
25,864 KB
testcase_21 AC 53 ms
15,520 KB
testcase_22 AC 80 ms
20,188 KB
testcase_23 AC 141 ms
28,820 KB
testcase_24 AC 19 ms
8,704 KB
testcase_25 AC 19 ms
8,660 KB
testcase_26 AC 18 ms
8,644 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 148 ms
30,740 KB
testcase_34 WA -
testcase_35 AC 108 ms
30,756 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 RE -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

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 dp[i - 1][0]:
            if s[i] == "a":
                dp[i][1] = True
            if s[i] == "o":
                dp[i][2] = True
        if dp[i - 1][1]:
            if s[i] == "w":
                dp[i][0] = True
            if s[i] == "n":
                dp[i][3] = True
        if dp[i - 1][2]:
            if s[i] == "w":
                dp[i][0] = True
            if s[i] == "n":
                dp[i][3] = True
        if dp[i - 1][3]:
            if s[i] == "w":
                dp[i][0] = True
            if s[i] == "n":
                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