結果

問題 No.1292 パタパタ三角形
ユーザー trineutrontrineutron
提出日時 2020-11-20 22:14:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 307 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 50,044 KB
最終ジャッジ日時 2024-07-23 13:11:05
合計ジャッジ時間 3,813 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,624 KB
testcase_01 AC 31 ms
10,496 KB
testcase_02 AC 32 ms
10,496 KB
testcase_03 AC 31 ms
10,624 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 29 ms
10,624 KB
testcase_06 AC 30 ms
10,624 KB
testcase_07 AC 293 ms
36,864 KB
testcase_08 AC 277 ms
32,256 KB
testcase_09 AC 301 ms
48,664 KB
testcase_10 AC 300 ms
48,916 KB
testcase_11 AC 305 ms
48,844 KB
testcase_12 AC 307 ms
50,044 KB
testcase_13 AC 297 ms
50,012 KB
testcase_14 AC 245 ms
25,216 KB
testcase_15 AC 251 ms
25,088 KB
testcase_16 AC 267 ms
25,216 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