結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,348 KB
testcase_01 AC 16 ms
8,444 KB
testcase_02 AC 15 ms
8,196 KB
testcase_03 AC 16 ms
8,268 KB
testcase_04 AC 15 ms
8,340 KB
testcase_05 AC 15 ms
8,248 KB
testcase_06 AC 17 ms
8,244 KB
testcase_07 AC 15 ms
8,364 KB
testcase_08 AC 16 ms
8,268 KB
testcase_09 AC 16 ms
8,272 KB
testcase_10 AC 16 ms
8,316 KB
testcase_11 AC 16 ms
8,344 KB
testcase_12 AC 16 ms
8,304 KB
testcase_13 AC 16 ms
8,424 KB
testcase_14 AC 163 ms
26,040 KB
testcase_15 AC 38 ms
11,104 KB
testcase_16 AC 170 ms
27,676 KB
testcase_17 AC 56 ms
13,552 KB
testcase_18 AC 20 ms
8,564 KB
testcase_19 AC 52 ms
15,660 KB
testcase_20 AC 110 ms
25,444 KB
testcase_21 AC 50 ms
15,132 KB
testcase_22 AC 79 ms
19,828 KB
testcase_23 AC 137 ms
28,556 KB
testcase_24 AC 15 ms
8,272 KB
testcase_25 AC 16 ms
8,148 KB
testcase_26 AC 16 ms
8,240 KB
testcase_27 AC 15 ms
8,248 KB
testcase_28 AC 15 ms
8,316 KB
testcase_29 AC 16 ms
8,144 KB
testcase_30 AC 16 ms
8,324 KB
testcase_31 AC 16 ms
8,196 KB
testcase_32 AC 203 ms
30,444 KB
testcase_33 AC 149 ms
30,488 KB
testcase_34 AC 322 ms
30,396 KB
testcase_35 AC 147 ms
30,448 KB
testcase_36 AC 187 ms
30,384 KB
testcase_37 AC 184 ms
30,504 KB
testcase_38 AC 185 ms
30,532 KB
testcase_39 AC 180 ms
30,432 KB
testcase_40 AC 195 ms
30,436 KB
testcase_41 AC 195 ms
30,528 KB
testcase_42 AC 206 ms
30,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    print("Yes") if dp[n][1] or dp[n][2] or dp[n][3] else print("No")


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