結果

問題 No.2373 wa, wo, n
ユーザー poyonpoyon
提出日時 2023-06-23 18:52:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 79,216 KB
最終ジャッジ日時 2023-09-15 06:55:07
合計ジャッジ時間 6,034 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,176 KB
testcase_01 AC 72 ms
71,336 KB
testcase_02 AC 72 ms
71,252 KB
testcase_03 AC 72 ms
71,088 KB
testcase_04 AC 71 ms
71,444 KB
testcase_05 AC 72 ms
71,316 KB
testcase_06 AC 70 ms
71,324 KB
testcase_07 AC 72 ms
71,200 KB
testcase_08 AC 71 ms
71,272 KB
testcase_09 AC 70 ms
71,096 KB
testcase_10 AC 70 ms
71,292 KB
testcase_11 AC 70 ms
71,308 KB
testcase_12 AC 69 ms
71,432 KB
testcase_13 AC 70 ms
71,432 KB
testcase_14 AC 150 ms
79,012 KB
testcase_15 AC 106 ms
77,436 KB
testcase_16 AC 154 ms
79,164 KB
testcase_17 AC 113 ms
77,660 KB
testcase_18 AC 102 ms
76,956 KB
testcase_19 AC 73 ms
75,696 KB
testcase_20 AC 76 ms
76,556 KB
testcase_21 AC 73 ms
75,828 KB
testcase_22 AC 75 ms
75,988 KB
testcase_23 AC 77 ms
76,884 KB
testcase_24 AC 73 ms
71,396 KB
testcase_25 AC 71 ms
71,272 KB
testcase_26 AC 71 ms
71,420 KB
testcase_27 AC 70 ms
71,420 KB
testcase_28 AC 73 ms
71,248 KB
testcase_29 AC 71 ms
71,516 KB
testcase_30 AC 72 ms
71,348 KB
testcase_31 AC 71 ms
71,312 KB
testcase_32 AC 159 ms
78,864 KB
testcase_33 AC 78 ms
76,988 KB
testcase_34 AC 187 ms
78,536 KB
testcase_35 AC 76 ms
76,884 KB
testcase_36 AC 138 ms
78,864 KB
testcase_37 AC 142 ms
78,832 KB
testcase_38 AC 135 ms
78,768 KB
testcase_39 AC 133 ms
78,612 KB
testcase_40 AC 158 ms
79,164 KB
testcase_41 AC 149 ms
79,216 KB
testcase_42 AC 143 ms
78,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().rstrip()

    def match(S, P):
        assert(len(S) == len(P))
        for s, p in zip(S, P):
            if (s == p or s == '?'): continue
            return False
        return True

    patterns = ("wa", "wo", "n")

    # dp[i] := S[0,i) が wawon 文字列であるか否か
    dp = [False] * (N + 1)
    dp[0] = True
    for i in range(N):
        if not dp[i]: continue
        for p in patterns:
            n = len(p)
            if (i + n <= N and match(S[i:i + n], p)):
                dp[i + n] = True

    ans = "Yes" if dp[N] else "No"
    print(ans)


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