結果
問題 | No.1226 I hate Robot Arms |
ユーザー | Mitarushi |
提出日時 | 2020-09-12 08:38:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 862 ms / 2,000 ms |
コード長 | 2,076 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 82,504 KB |
実行使用メモリ | 118,512 KB |
最終ジャッジ日時 | 2024-06-10 11:41:28 |
合計ジャッジ時間 | 22,333 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
53,376 KB |
testcase_01 | AC | 36 ms
54,368 KB |
testcase_02 | AC | 407 ms
86,264 KB |
testcase_03 | AC | 432 ms
89,796 KB |
testcase_04 | AC | 487 ms
101,628 KB |
testcase_05 | AC | 450 ms
101,560 KB |
testcase_06 | AC | 758 ms
116,064 KB |
testcase_07 | AC | 397 ms
86,552 KB |
testcase_08 | AC | 325 ms
94,976 KB |
testcase_09 | AC | 593 ms
95,984 KB |
testcase_10 | AC | 254 ms
81,968 KB |
testcase_11 | AC | 511 ms
102,900 KB |
testcase_12 | AC | 376 ms
90,964 KB |
testcase_13 | AC | 374 ms
97,072 KB |
testcase_14 | AC | 621 ms
97,524 KB |
testcase_15 | AC | 248 ms
93,636 KB |
testcase_16 | AC | 741 ms
115,820 KB |
testcase_17 | AC | 372 ms
87,012 KB |
testcase_18 | AC | 333 ms
87,236 KB |
testcase_19 | AC | 538 ms
104,408 KB |
testcase_20 | AC | 478 ms
101,716 KB |
testcase_21 | AC | 541 ms
105,348 KB |
testcase_22 | AC | 806 ms
117,184 KB |
testcase_23 | AC | 862 ms
117,836 KB |
testcase_24 | AC | 833 ms
118,512 KB |
testcase_25 | AC | 762 ms
116,764 KB |
testcase_26 | AC | 784 ms
118,172 KB |
testcase_27 | AC | 758 ms
111,208 KB |
testcase_28 | AC | 747 ms
111,460 KB |
testcase_29 | AC | 753 ms
110,776 KB |
ソースコード
from math import sin, cos, pi p = pi / 180 class SegmentTree: def __init__(self, a, func=max, one=-10 ** 18): self.logn = (len(a) - 1).bit_length() self.n = 1 << self.logn self.func = func self.one = one self.b = [self.one] * (2 * self.n - 1) for i, j in enumerate(a): self.b[i + self.n - 1] = j for i in reversed(range(self.n - 1)): self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) def get_item(self, i): return self.b[i + self.n - 1] def update(self, index, x): i = index + self.n - 1 self.b[i] = x while i != 0: i = (i - 1) // 2 self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) def update_func(self, index, x): i = index + self.n - 1 self.b[i] = self.func(self.b[i], x) while i != 0: i = (i - 1) // 2 self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2]) def get_segment(self, l, r): l += self.n r += self.n s = self.one t = self.one while l < r: if l & 1: s = self.func(s, self.b[l - 1]) l += 1 if r & 1: r -= 1 t = self.func(self.b[r - 1], t) l >>= 1 r >>= 1 return self.func(s, t) n, q = map(int, input().split()) def merge(a, b): (x1, y1), t1 = a (x2, y2), t2 = b x = x1 + x2*cos(t1*p) - y2*sin(t1*p) y = y1 + x2*sin(t1*p) + y2 * cos(t1*p) return (x, y), t1+t2 seg = SegmentTree([((1, 0), 0) for _ in range(n)], merge, [[0, 0], 0]) d = [1] * n th = [0] * n for _ in range(q): qu, *x = map(int, input().split()) if qu == 2: print(*seg.get_segment(0, x[0])[0]) else: a, b = x if qu == 0: th[a-1] = b c = ((d[a-1] * cos(b*p), d[a-1] * sin(b*p)), b) else: d[a-1] = b e = th[a-1] c = ((b * cos(e*p), b * sin(e*p)), e) seg.update(a-1, c)