結果

問題 No.675 ドットちゃんたち
ユーザー maspymaspy
提出日時 2020-01-06 11:09:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,239 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 48,416 KB
最終ジャッジ日時 2023-08-14 22:36:05
合計ジャッジ時間 10,737 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
29,408 KB
testcase_01 AC 129 ms
29,404 KB
testcase_02 AC 125 ms
29,424 KB
testcase_03 AC 125 ms
29,496 KB
testcase_04 AC 131 ms
29,480 KB
testcase_05 AC 1,239 ms
42,816 KB
testcase_06 AC 1,162 ms
48,416 KB
testcase_07 AC 1,103 ms
45,780 KB
testcase_08 AC 1,180 ms
43,508 KB
testcase_09 AC 1,221 ms
47,900 KB
testcase_10 AC 1,173 ms
47,596 KB
testcase_11 AC 1,236 ms
48,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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