結果

問題 No.1292 パタパタ三角形
ユーザー tcltktcltk
提出日時 2020-11-20 22:52:27
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 1,007 bytes
コンパイル時間 288 ms
使用メモリ 35,080 KB
最終ジャッジ日時 2023-02-23 19:16:09
合計ジャッジ時間 2,411 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 12 ms
7,764 KB
testcase_01 AC 13 ms
7,744 KB
testcase_02 AC 14 ms
7,660 KB
testcase_03 AC 13 ms
7,748 KB
testcase_04 AC 13 ms
7,700 KB
testcase_05 AC 13 ms
7,708 KB
testcase_06 AC 13 ms
7,720 KB
testcase_07 AC 108 ms
13,608 KB
testcase_08 AC 103 ms
12,868 KB
testcase_09 AC 155 ms
34,780 KB
testcase_10 AC 167 ms
34,448 KB
testcase_11 AC 159 ms
34,292 KB
testcase_12 AC 160 ms
35,040 KB
testcase_13 AC 149 ms
35,080 KB
testcase_14 AC 91 ms
8,188 KB
testcase_15 AC 89 ms
8,240 KB
testcase_16 AC 95 ms
8,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *



# def solve(S: str) -> int:
def solve(S):
    t = set()
    t.add((0, 0))
    x, y = 0, 0
    tri = ['a', 'b', 'c']
    tri_upper = True
    for s in S:
        index = tri.index(s)
        if tri_upper:
            if index == 0:
                x -= 1
                tri = [tri[2], tri[0], tri[1]]
            elif index == 1:
                x += 1
                tri = [tri[1], tri[2], tri[0]]
            else:
                y -= 1
                tri = [tri[0], tri[1], tri[2]]
        else:
            if index == 0:
                x -= 1
                tri = [tri[2], tri[0], tri[1]]
            elif index == 1:
                x += 1
                tri = [tri[1], tri[2], tri[0]]
            else:
                y += 1
                tri = [tri[0], tri[1], tri[2]]
        tri_upper = not tri_upper
        t.add((x, y))
    return len(t)

def main():
    S = input()
    a = solve(S)
    print(a)

if __name__ == '__main__':
    main()
0