結果

問題 No.2373 wa, wo, n
ユーザー ThetaTheta
提出日時 2023-10-13 18:08:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 2,229 bytes
コンパイル時間 1,205 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 9,740 KB
最終ジャッジ日時 2023-10-13 18:08:13
合計ジャッジ時間 3,423 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
9,140 KB
testcase_01 AC 23 ms
9,188 KB
testcase_02 AC 23 ms
9,296 KB
testcase_03 AC 23 ms
9,192 KB
testcase_04 AC 23 ms
9,308 KB
testcase_05 AC 23 ms
9,324 KB
testcase_06 AC 23 ms
9,168 KB
testcase_07 AC 23 ms
9,304 KB
testcase_08 AC 24 ms
9,188 KB
testcase_09 AC 23 ms
9,360 KB
testcase_10 AC 22 ms
9,308 KB
testcase_11 AC 23 ms
9,196 KB
testcase_12 AC 23 ms
9,168 KB
testcase_13 AC 24 ms
9,168 KB
testcase_14 AC 77 ms
9,484 KB
testcase_15 AC 33 ms
9,384 KB
testcase_16 AC 85 ms
9,596 KB
testcase_17 AC 41 ms
9,484 KB
testcase_18 AC 24 ms
9,188 KB
testcase_19 AC 27 ms
9,328 KB
testcase_20 AC 35 ms
9,564 KB
testcase_21 AC 28 ms
9,316 KB
testcase_22 AC 31 ms
9,412 KB
testcase_23 AC 35 ms
9,556 KB
testcase_24 AC 25 ms
9,360 KB
testcase_25 AC 23 ms
9,352 KB
testcase_26 AC 23 ms
9,356 KB
testcase_27 AC 22 ms
9,160 KB
testcase_28 AC 22 ms
9,376 KB
testcase_29 AC 22 ms
9,140 KB
testcase_30 AC 22 ms
9,300 KB
testcase_31 AC 22 ms
9,376 KB
testcase_32 AC 96 ms
9,684 KB
testcase_33 AC 36 ms
9,740 KB
testcase_34 AC 164 ms
9,552 KB
testcase_35 AC 36 ms
9,592 KB
testcase_36 AC 86 ms
9,676 KB
testcase_37 AC 77 ms
9,740 KB
testcase_38 AC 78 ms
9,568 KB
testcase_39 AC 109 ms
9,684 KB
testcase_40 AC 84 ms
9,552 KB
testcase_41 AC 86 ms
9,524 KB
testcase_42 AC 81 ms
9,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from re import compile
import sys


def printe(*args, end="\n"):
    print(*args, end=end, file=sys.stderr)


def main():
    N = int(input())
    S = input()
    ctr = Counter(S)
    if len(S) > ctr["w"] + ctr["a"] + ctr["o"] + ctr["n"] + ctr["?"]:
        print("No")

        return

    idx = 0
    while idx < N:
        if idx == N - 1:
            if S[idx] in ("?", "n"):
                print("Yes")
            else:
                print("No")
                printe(S[idx - 10:idx + 10])
            return

        if idx == N - 2:
            if S[idx] == "w":
                if S[idx + 1] in ("a", "o", "?"):
                    print("Yes")
                else:
                    print("No")
                    printe(S[idx - 10:idx + 10])
                return
            if S[idx] in ("a", "o"):
                print("No")
                printe(S[idx - 10:idx + 10])
                return
            if S[idx] == "n":
                if S[idx + 1] in ("n", "?"):
                    print("Yes")
                else:
                    print("No")
                    printe(S[idx - 10:idx + 10])
                return
            if S[idx] == "?":
                if S[idx + 1] == "w":
                    print("No")
                    printe(S[idx - 10:idx + 10])
                else:
                    print("Yes")
                return

        l_1, l_2, l_3 = S[idx:idx + 3]
        if l_1 in ("a", "o"):
            print("No")
            printe(S[idx - 10:idx + 10])
            return
        if l_1 == "n":
            idx += 1
            continue
        if l_1 == "w":
            if l_2 in ("a", "o", "?"):
                idx += 2
                continue
            print("No")
            printe(S[idx - 10:idx + 10])
            return
        if l_1 == "?":
            if l_2 == "w":
                idx += 1
                continue
            if l_2 != "?":
                idx += 2
                continue
            if l_3 == "w":
                idx += 2
                continue
            if l_3 in ("a", "o", "n"):
                idx += 3
                continue
            idx += 1


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