結果
問題 | No.1932 動く点 P / Moving Point P |
ユーザー | tamato |
提出日時 | 2022-05-06 23:18:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,822 ms / 6,000 ms |
コード長 | 3,701 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 82,472 KB |
実行使用メモリ | 176,864 KB |
最終ジャッジ日時 | 2024-07-06 02:03:24 |
合計ジャッジ時間 | 35,930 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
53,996 KB |
testcase_01 | AC | 1,270 ms
160,260 KB |
testcase_02 | AC | 750 ms
156,472 KB |
testcase_03 | AC | 1,909 ms
95,632 KB |
testcase_04 | AC | 2,378 ms
112,004 KB |
testcase_05 | AC | 1,664 ms
105,696 KB |
testcase_06 | AC | 333 ms
117,560 KB |
testcase_07 | AC | 3,822 ms
176,864 KB |
testcase_08 | AC | 3,808 ms
176,228 KB |
testcase_09 | AC | 1,910 ms
169,048 KB |
testcase_10 | AC | 1,863 ms
168,928 KB |
testcase_11 | AC | 1,986 ms
169,172 KB |
ソースコード
mod = 998244353 def main(): import sys from math import cos, sin, pi input = sys.stdin.readline def matmul(A, B): C = [[0] * len(B[0]) for _ in range(len(A))] for i in range(len(A)): for k in range(len(B)): for j in range(len(B[0])): C[i][j] = C[i][j] + A[i][k] * B[k][j] return C def matpow(A, p): n = len(A) B = [[0] * n for _ in range(n)] for i in range(n): B[i][i] = 1 while p > 0: if p & 1: B = matmul(B, A) A = matmul(A, A) p >>= 1 return B class SegmentTree: def __init__(self, A, initialize=True, segfunc=min, ident=2000000000): self.N = len(A) self.LV = (self.N - 1).bit_length() self.N0 = 1 << self.LV self.segfunc = segfunc self.ident = ident if initialize: self.data = [self.ident] * self.N0 + A + [self.ident] * (self.N0 - self.N) for i in range(self.N0 - 1, 0, -1): self.data[i] = segfunc(self.data[i * 2], self.data[i * 2 + 1]) else: self.data = [self.ident] * (self.N0 * 2) def update(self, i, x): i += self.N0 - 1 self.data[i] = x for _ in range(self.LV): i >>= 1 self.data[i] = self.segfunc(self.data[i * 2], self.data[i * 2 + 1]) def get(self, i): return self.data[i + self.N0 - 1] # open interval [l, r) def query(self, l, r): l += self.N0 - 1 r += self.N0 - 1 ret_l = self.ident ret_r = self.ident while l < r: if l & 1: ret_l = self.segfunc(ret_l, self.data[l]) l += 1 if r & 1: ret_r = self.segfunc(self.data[r - 1], ret_r) r -= 1 l >>= 1 r >>= 1 return self.segfunc(ret_l, ret_r) # return smallest i(l <= i < r) s.t. check(A[i]) == True def binsearch(self, l, r, check): if not check(self.query(l, r)): return r l += self.N0 - 1 val = self.ident while True: if check(self.segfunc(val, self.data[l])): break if l & 1: val = self.segfunc(val, self.data[l]) l += 1 l >>= 1 while l < self.N0: newval = self.segfunc(val, self.data[l * 2]) if not check(newval): val = newval l = (l << 1) + 1 else: l <<= 1 return l - self.N0 + 1 N = int(input()) trans_list = [] for _ in range(N): p, q, r = map(float, input().split()) cos_r = cos(r * pi / 180) sin_r = sin(r * pi / 180) trans_list.append([ [cos_r, -sin_r, p * (1 - cos_r) + q * sin_r], [sin_r, cos_r, -p * sin_r + q * (1 - cos_r)], [0, 0, 1] ]) trans_list.reverse() ST = SegmentTree(trans_list, segfunc=matmul, ident=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]) for _ in range(int(input())): s, t, x, y = map(float, input().split()) s = int(s) t = int(t) trans = ST.query(N - t + 1, N - s + 2) #print(trans) vec = [[x], [y], [1]] vec_new = matmul(trans, vec) print(vec_new[0][0], vec_new[1][0]) #print(vec_new) if __name__ == '__main__': main()