結果

問題 No.2373 wa, wo, n
ユーザー ThetaTheta
提出日時 2023-10-13 18:00:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,825 bytes
コンパイル時間 1,027 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 9,668 KB
最終ジャッジ日時 2023-10-13 18:00:26
合計ジャッジ時間 4,083 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
9,252 KB
testcase_01 AC 26 ms
9,208 KB
testcase_02 AC 28 ms
9,164 KB
testcase_03 AC 26 ms
9,096 KB
testcase_04 AC 27 ms
9,164 KB
testcase_05 AC 27 ms
9,100 KB
testcase_06 AC 27 ms
9,212 KB
testcase_07 AC 26 ms
9,204 KB
testcase_08 AC 27 ms
9,164 KB
testcase_09 AC 27 ms
9,224 KB
testcase_10 AC 27 ms
9,108 KB
testcase_11 AC 27 ms
9,120 KB
testcase_12 AC 27 ms
9,124 KB
testcase_13 AC 27 ms
9,168 KB
testcase_14 WA -
testcase_15 AC 28 ms
9,284 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 32 ms
9,236 KB
testcase_20 AC 39 ms
9,456 KB
testcase_21 AC 32 ms
9,280 KB
testcase_22 AC 35 ms
9,388 KB
testcase_23 AC 39 ms
9,460 KB
testcase_24 AC 28 ms
9,196 KB
testcase_25 AC 27 ms
9,260 KB
testcase_26 AC 26 ms
9,192 KB
testcase_27 AC 27 ms
9,096 KB
testcase_28 AC 27 ms
9,092 KB
testcase_29 AC 27 ms
9,100 KB
testcase_30 WA -
testcase_31 AC 27 ms
9,256 KB
testcase_32 WA -
testcase_33 AC 42 ms
9,544 KB
testcase_34 AC 176 ms
9,532 KB
testcase_35 AC 41 ms
9,612 KB
testcase_36 AC 96 ms
9,576 KB
testcase_37 AC 86 ms
9,500 KB
testcase_38 AC 86 ms
9,588 KB
testcase_39 AC 121 ms
9,496 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 86 ms
9,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from re import compile


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")
            return

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

        l_1, l_2, l_3 = S[idx:idx + 3]
        if l_1 in ("a", "o"):
            print("No")
            return
        if l_1 == "n":
            idx += 1
            continue
        if l_1 == "w":
            if l_2 in ("a", "o", "?"):
                idx += 2
                continue
            print("No")
            return
        if l_1 == "?":
            if l_2 == "w":
                print("No")
                return
            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