結果

問題 No.1292 パタパタ三角形
ユーザー maninimanini
提出日時 2021-01-25 17:58:38
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 1,393 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 109,324 KB
最終ジャッジ日時 2023-09-04 12:11:25
合計ジャッジ時間 3,667 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,020 KB
testcase_01 AC 75 ms
70,972 KB
testcase_02 AC 79 ms
71,088 KB
testcase_03 AC 74 ms
71,304 KB
testcase_04 AC 75 ms
71,268 KB
testcase_05 AC 77 ms
71,260 KB
testcase_06 AC 76 ms
71,088 KB
testcase_07 AC 179 ms
83,168 KB
testcase_08 AC 176 ms
82,112 KB
testcase_09 AC 208 ms
109,324 KB
testcase_10 AC 203 ms
108,568 KB
testcase_11 AC 209 ms
108,980 KB
testcase_12 AC 161 ms
108,460 KB
testcase_13 AC 161 ms
108,736 KB
testcase_14 AC 101 ms
76,328 KB
testcase_15 AC 101 ms
76,580 KB
testcase_16 AC 101 ms
76,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:UTF-8
import sys

MOD = 10 ** 9 + 7
INF = float('inf')

S = input()     # 文字列

mp = {(0, 0)}
pos = [0, 0]
mode = [0, 0]

for s in S:
    if (mode == [0, 0] and s == "c") or (mode == [0, 1] and s == "a") or (mode == [0, 2] and s == "b"):
        pos[1] += 1
        mode[0] = 1
        mp.add((pos[0], pos[1]))
    elif (mode == [0, 0] and s == "b") or (mode == [0, 1] and s == "c") or (mode == [0, 2] and s == "a"):
        pos[0] += 1
        mode[0] = 1
        mode[1] = (mode[1] + 1) % 3
        mp.add((pos[0], pos[1]))
    elif (mode == [0, 0] and s == "a") or (mode == [0, 1] and s == "b") or (mode == [0, 2] and s == "c"):
        pos[0] -= 1
        mode[0] = 1
        mode[1] = (mode[1] - 1) % 3
        mp.add((pos[0], pos[1]))
    elif (mode == [1, 0] and s == "c") or (mode == [1, 1] and s == "a") or (mode == [1, 2] and s == "b"):
        pos[1] -= 1
        mode[0] = 0
        mp.add((pos[0], pos[1]))
    elif (mode == [1, 0] and s == "b") or (mode == [1, 1] and s == "c") or (mode == [1, 2] and s == "a"):
        pos[0] += 1
        mode[0] = 0
        mode[1] = (mode[1] + 1) % 3
        mp.add((pos[0], pos[1]))
    elif (mode == [1, 0] and s == "a") or (mode == [1, 1] and s == "b") or (mode == [1, 2] and s == "c"):
        pos[0] -= 1
        mode[0] = 0
        mode[1] = (mode[1] - 1) % 3
        mp.add((pos[0], pos[1]))

print("{}".format(len(mp)))
0