結果
| 問題 |
No.1292 パタパタ三角形
|
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2020-11-20 22:14:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
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)))
trineutron