結果

問題 No.675 ドットちゃんたち
コンテスト
ユーザー H3PO4
提出日時 2024-04-12 14:17:50
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 1,297 ms / 2,000 ms
+ 404µs
コード長 753 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 584 ms
コンパイル使用メモリ 21,408 KB
実行使用メモリ 62,500 KB
最終ジャッジ日時 2026-07-21 07:58:21
合計ジャッジ時間 15,391 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import numpy as np

N, Px, Py = map(int, input().split())
matrices = []
matrix = np.diag(np.ones(3, dtype=np.int64))
x0 = np.array([Px, Py, 1], dtype=np.int64)

C = [tuple(map(int, input().split())) for _ in range(N)]
for cmd in reversed(C):
    if cmd[0] == 1:
        matr_x = np.array([[1, 0, 0], [0, 1, 0], [cmd[1], 0, 1]], dtype=np.int64)
        matrix = matr_x @ matrix
    elif cmd[0] == 2:
        matr_y = np.array([[1, 0, 0], [0, 1, 0], [0, cmd[1], 1]], dtype=np.int64)
        matrix = matr_y @ matrix
    elif cmd[0] == 3:
        matr_r = np.array([[0, -1, 0], [1, 0, 0], [0, 0, 1]], dtype=np.int64)
        matrix = matr_r @ matrix

    matrices.append(matrix)

for matrix in reversed(matrices):
    x, y, _ = x0 @ matrix
    print(x, y)
0