結果

問題 No.1292 パタパタ三角形
ユーザー trineutrontrineutron
提出日時 2020-11-20 22:14:42
言語 Python3
(3.11.2 + numpy 1.24.2 + scipy 1.10.1)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 66 ms
実行使用メモリ 47,040 KB
最終ジャッジ日時 2023-02-23 18:33:50
合計ジャッジ時間 4,735 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,648 KB
testcase_01 AC 16 ms
7,664 KB
testcase_02 AC 15 ms
7,744 KB
testcase_03 AC 15 ms
7,640 KB
testcase_04 AC 16 ms
7,768 KB
testcase_05 AC 16 ms
7,724 KB
testcase_06 AC 16 ms
7,824 KB
testcase_07 AC 283 ms
33,804 KB
testcase_08 AC 280 ms
29,564 KB
testcase_09 AC 304 ms
45,488 KB
testcase_10 AC 304 ms
45,976 KB
testcase_11 AC 306 ms
45,736 KB
testcase_12 AC 302 ms
46,900 KB
testcase_13 AC 303 ms
47,040 KB
testcase_14 AC 236 ms
22,228 KB
testcase_15 AC 258 ms
22,132 KB
testcase_16 AC 271 ms
22,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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