結果

問題 No.1292 パタパタ三角形
ユーザー trineutrontrineutron
提出日時 2020-11-20 22:14:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 47,368 KB
最終ジャッジ日時 2023-09-30 19:24:28
合計ジャッジ時間 3,736 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,816 KB
testcase_01 AC 16 ms
7,820 KB
testcase_02 AC 15 ms
7,740 KB
testcase_03 AC 16 ms
7,744 KB
testcase_04 AC 15 ms
7,812 KB
testcase_05 AC 15 ms
7,928 KB
testcase_06 AC 16 ms
7,796 KB
testcase_07 AC 255 ms
34,180 KB
testcase_08 AC 247 ms
29,660 KB
testcase_09 AC 266 ms
45,840 KB
testcase_10 AC 266 ms
46,140 KB
testcase_11 AC 264 ms
46,068 KB
testcase_12 AC 262 ms
47,216 KB
testcase_13 AC 270 ms
47,368 KB
testcase_14 AC 209 ms
22,600 KB
testcase_15 AC 222 ms
22,452 KB
testcase_16 AC 240 ms
22,380 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