結果

問題 No.2373 wa, wo, n
ユーザー ThetaTheta
提出日時 2023-10-13 18:07:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 2,265 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 9,764 KB
最終ジャッジ日時 2023-10-13 18:07:32
合計ジャッジ時間 4,620 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
9,208 KB
testcase_01 AC 24 ms
9,224 KB
testcase_02 AC 27 ms
9,192 KB
testcase_03 RE -
testcase_04 AC 23 ms
9,196 KB
testcase_05 AC 23 ms
9,336 KB
testcase_06 AC 24 ms
9,272 KB
testcase_07 AC 25 ms
9,224 KB
testcase_08 AC 24 ms
9,148 KB
testcase_09 AC 25 ms
9,376 KB
testcase_10 AC 25 ms
9,192 KB
testcase_11 AC 25 ms
9,308 KB
testcase_12 AC 25 ms
9,324 KB
testcase_13 AC 24 ms
9,236 KB
testcase_14 AC 80 ms
9,628 KB
testcase_15 AC 33 ms
9,400 KB
testcase_16 AC 92 ms
9,616 KB
testcase_17 AC 40 ms
9,352 KB
testcase_18 AC 26 ms
9,236 KB
testcase_19 AC 27 ms
9,344 KB
testcase_20 AC 33 ms
9,520 KB
testcase_21 AC 27 ms
9,444 KB
testcase_22 AC 31 ms
9,444 KB
testcase_23 AC 35 ms
9,580 KB
testcase_24 AC 24 ms
9,304 KB
testcase_25 AC 24 ms
9,208 KB
testcase_26 AC 24 ms
9,320 KB
testcase_27 AC 24 ms
9,216 KB
testcase_28 AC 25 ms
9,260 KB
testcase_29 AC 24 ms
9,332 KB
testcase_30 AC 23 ms
9,372 KB
testcase_31 AC 23 ms
9,372 KB
testcase_32 AC 87 ms
9,680 KB
testcase_33 AC 36 ms
9,764 KB
testcase_34 AC 159 ms
9,600 KB
testcase_35 RE -
testcase_36 AC 100 ms
9,644 KB
testcase_37 AC 81 ms
9,624 KB
testcase_38 AC 82 ms
9,576 KB
testcase_39 AC 118 ms
9,680 KB
testcase_40 AC 93 ms
9,600 KB
testcase_41 AC 88 ms
9,656 KB
testcase_42 AC 86 ms
9,584 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")
        printe(S[idx - 10:idx + 10])
        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