結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-11-20 22:52:27 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 206 ms / 2,000 ms | 
| コード長 | 1,007 bytes | 
| コンパイル時間 | 122 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 38,028 KB | 
| 最終ジャッジ日時 | 2024-07-23 13:34:19 | 
| 合計ジャッジ時間 | 2,540 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
#!/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()
            
            
            
        