結果

問題 No.1292 パタパタ三角形
コンテスト
ユーザー trineutron
提出日時 2020-11-20 22:14:42
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 620 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 563 ms
コンパイル使用メモリ 20,956 KB
実行使用メモリ 53,516 KB
最終ジャッジ日時 2026-04-03 14:28:24
合計ジャッジ時間 4,088 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

s = input()
x = [(0, 0)]
a = (1, 0)
b = (0, 1)

def flip(c, a, b):
    if c == 'a':
        res_a = -a[0], -a[1]
        res_b = a[0] + b[0], a[1] + b[1]
    elif c == 'b':
        res_a = a[0] + b[0], a[1] + b[1]
        res_b = -b[0], -b[1]
    else:
        res_a = -b[0], -b[1]
        res_b = -a[0], -a[1]
    return res_a, res_b

for c in s:
    if c == 'a':
        newx = x[-1][0] + a[0], x[-1][1] + a[1]
    elif c == 'b':
        newx = x[-1][0] + b[0], x[-1][1] + b[1]
    else:
        newx = x[-1][0] - (a[0] + b[0]), x[-1][1] - (a[1] + b[1])
    a, b = flip(c, a, b)
    x.append(newx)

print(len(set(x)))
0