結果

問題 No.1292 パタパタ三角形
ユーザー maninimanini
提出日時 2021-01-25 17:58:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 1,393 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 107,588 KB
最終ジャッジ日時 2024-06-22 10:53:54
合計ジャッジ時間 3,000 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,688 KB
testcase_01 AC 39 ms
53,576 KB
testcase_02 AC 39 ms
52,624 KB
testcase_03 AC 38 ms
52,508 KB
testcase_04 AC 39 ms
53,284 KB
testcase_05 AC 40 ms
53,376 KB
testcase_06 AC 38 ms
52,940 KB
testcase_07 AC 147 ms
82,084 KB
testcase_08 AC 142 ms
81,016 KB
testcase_09 AC 173 ms
103,676 KB
testcase_10 AC 173 ms
103,704 KB
testcase_11 AC 172 ms
104,496 KB
testcase_12 AC 127 ms
107,512 KB
testcase_13 AC 131 ms
107,588 KB
testcase_14 AC 65 ms
70,520 KB
testcase_15 AC 67 ms
69,392 KB
testcase_16 AC 61 ms
67,324 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