結果

問題 No.675 ドットちゃんたち
コンテスト
ユーザー maspy
提出日時 2020-01-06 11:09:57
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 1,943 ms / 2,000 ms
コード長 677 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 703 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 53,464 KB
最終ジャッジ日時 2026-02-22 16:17:39
合計ジャッジ時間 22,751 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,px,py = map(int,readline().split())
CMD = readlines()

answer = []
mat = np.eye(3,dtype=np.int64)
v = np.array([px,py,1],np.int64).reshape(-1,1)
for cmd in CMD[::-1]:
    t,*data = map(int,cmd.split())
    if t == 3:
        mat[:2,:2] = np.dot(mat[:2,:2], np.array([[0,1],[-1,0]],np.int64))
    elif t == 1:
        d = data[0]
        mat[:,2] += d * mat[:,0]
    elif t == 2:
        d = data[0]
        mat[:,2] += d * mat[:,1]
    x,y = np.dot(mat,v).ravel()[:2]
    answer.append('{} {}'.format(x,y))

print('\n'.join(answer[::-1]))
0