結果
問題 |
No.675 ドットちゃんたち
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:27:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 287 ms / 2,000 ms |
コード長 | 1,251 bytes |
コンパイル時間 | 215 ms |
コンパイル使用メモリ | 82,344 KB |
実行使用メモリ | 95,660 KB |
最終ジャッジ日時 | 2025-03-20 20:28:47 |
合計ジャッジ時間 | 3,551 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 8 |
ソースコード
def rotate_point(r, x, y): if r == 0: return x, y elif r == 1: return y, -x elif r == 2: return -x, -y else: # r == 3 return -y, x n, Px, Py = map(int, input().split()) commands = [] for _ in range(n): parts = input().split() if parts[0] == '1': dx = int(parts[1]) commands.append(('1', dx)) elif parts[0] == '2': dy = int(parts[1]) commands.append(('2', dy)) else: commands.append(('3',)) # Initialize transformations array transformations = [(0, 0, 0)] * (n + 1) transformations[n] = (0, 0, 0) for i in range(n - 1, -1, -1): cmd = commands[i] r_t, dx_t, dy_t = 0, 0, 0 if cmd[0] == '1': dx_t = cmd[1] elif cmd[0] == '2': dy_t = cmd[1] elif cmd[0] == '3': r_t = 1 r_next, dx_next, dy_next = transformations[i + 1] composed_r = (r_t + r_next) % 4 rotated_dx, rotated_dy = rotate_point(r_next, dx_t, dy_t) new_dx = rotated_dx + dx_next new_dy = rotated_dy + dy_next transformations[i] = (composed_r, new_dx, new_dy) for k in range(n): r, dx, dy = transformations[k] px_rot, py_rot = rotate_point(r, Px, Py) ax = px_rot + dx ay = py_rot + dy print(ax, ay)