結果

問題 No.675 ドットちゃんたち
ユーザー rlangevinrlangevin
提出日時 2023-09-14 12:08:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 547 ms / 2,000 ms
コード長 847 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 115,000 KB
最終ジャッジ日時 2023-09-14 12:08:26
合計ジャッジ時間 6,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,184 KB
testcase_01 AC 77 ms
71,320 KB
testcase_02 AC 76 ms
71,360 KB
testcase_03 AC 75 ms
71,528 KB
testcase_04 AC 74 ms
71,168 KB
testcase_05 AC 469 ms
114,996 KB
testcase_06 AC 519 ms
115,000 KB
testcase_07 AC 480 ms
110,976 KB
testcase_08 AC 540 ms
114,552 KB
testcase_09 AC 510 ms
114,252 KB
testcase_10 AC 547 ms
114,068 KB
testcase_11 AC 507 ms
114,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, px, py = map(int, input().split())
C = []
for i in range(N):
    C.append(list(map(int, input().split())))
C.reverse()
n = 0
def Mat(x, y, f):
    if f == 1:
        return [[0, 1, 0], [-1, 0, 0], [0, 0, 1]]
    return [[1, 0, x], [0, 1, y], [0, 0, 1]]

def Matprod(A, B):
    N = len(A)
    C = [[0] * len(B[0]) for i in range(N)]
    for i in range(N):
        for j in range(len(B[0])):
            for k in range(N):
                C[i][j] += A[i][k] * B[k][j]
    return C

ans = []
now = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
for c in C:
    if c[0] == 3:
        now = Matprod(now, Mat(-1, -1, 1))
    elif c[0] == 1:
        now = Matprod(now, Mat(c[1], 0, 0))
    else:
        now = Matprod(now, Mat(0, c[1], 0))

    x, y, _ = Matprod(now, [[px], [py], [1]])
    ans.append((x, y))

ans.reverse()
for x, y in ans:
    print(x[0], y[0]) 
0