結果

問題 No.1292 パタパタ三角形
ユーザー ayaoniayaoni
提出日時 2020-11-20 22:22:03
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 1,380 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 119,152 KB
最終ジャッジ日時 2023-09-30 19:31:04
合計ジャッジ時間 3,164 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,020 KB
testcase_01 AC 70 ms
70,900 KB
testcase_02 AC 72 ms
70,656 KB
testcase_03 AC 70 ms
70,784 KB
testcase_04 AC 72 ms
70,964 KB
testcase_05 AC 70 ms
70,740 KB
testcase_06 AC 71 ms
71,060 KB
testcase_07 AC 168 ms
85,808 KB
testcase_08 AC 171 ms
85,164 KB
testcase_09 AC 185 ms
109,516 KB
testcase_10 AC 209 ms
119,152 KB
testcase_11 AC 185 ms
109,656 KB
testcase_12 AC 171 ms
118,856 KB
testcase_13 AC 168 ms
118,572 KB
testcase_14 AC 102 ms
76,448 KB
testcase_15 AC 99 ms
76,228 KB
testcase_16 AC 100 ms
76,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def S(): return sys.stdin.readline().rstrip()


S = S()
ANS = set()

state = 1
a,b,c = 0,0,0
ANS.add((a,b,c))

for s in S:
    if state == 1:
        if s == 'a':
            state = 2
            a += 1
        elif s == 'b':
            state = 3
            b += 1
        else:
            state = 4
            c += 1
    elif state == 2:
        if s == 'a':
            state = 1
            a += -1
        elif s == 'b':
            state = 5
            c += -1
        else:
            state = 6
            b += -1
    elif state == 3:
        if s == 'a':
            state = 6
            c += -1
        elif s == 'b':
            state = 1
            b += -1
        else:
            state = 5
            a += -1
    elif state == 4:
        if s == 'a':
            state = 5
            b += -1
        elif s == 'b':
            state = 6
            a += -1
        else:
            state = 1
            c += -1
    elif state == 5:
        if s == 'a':
            state = 4
            b += 1
        elif s == 'b':
            state = 2
            c += 1
        else:
            state = 3
            a += 1
    else:
        if s == 'a':
            state = 3
            c += 1
        elif s == 'b':
            state = 4
            a += 1
        else:
            state = 2
            b += 1
    ANS.add((a,b,c))

print(len(ANS))
0