結果
問題 | No.1226 I hate Robot Arms |
ユーザー | uni_python |
提出日時 | 2020-09-13 00:16:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,175 ms / 2,000 ms |
コード長 | 2,902 bytes |
コンパイル時間 | 420 ms |
コンパイル使用メモリ | 82,404 KB |
実行使用メモリ | 197,952 KB |
最終ジャッジ日時 | 2025-01-02 15:07:35 |
合計ジャッジ時間 | 27,857 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,992 KB |
testcase_01 | AC | 38 ms
54,528 KB |
testcase_02 | AC | 467 ms
100,544 KB |
testcase_03 | AC | 530 ms
112,692 KB |
testcase_04 | AC | 626 ms
147,484 KB |
testcase_05 | AC | 580 ms
148,648 KB |
testcase_06 | AC | 1,097 ms
192,528 KB |
testcase_07 | AC | 459 ms
100,888 KB |
testcase_08 | AC | 325 ms
125,260 KB |
testcase_09 | AC | 697 ms
126,004 KB |
testcase_10 | AC | 253 ms
86,100 KB |
testcase_11 | AC | 665 ms
149,348 KB |
testcase_12 | AC | 462 ms
115,284 KB |
testcase_13 | AC | 397 ms
134,036 KB |
testcase_14 | AC | 830 ms
137,976 KB |
testcase_15 | AC | 272 ms
123,564 KB |
testcase_16 | AC | 1,087 ms
192,456 KB |
testcase_17 | AC | 453 ms
106,912 KB |
testcase_18 | AC | 361 ms
101,324 KB |
testcase_19 | AC | 669 ms
154,196 KB |
testcase_20 | AC | 652 ms
149,140 KB |
testcase_21 | AC | 765 ms
159,744 KB |
testcase_22 | AC | 1,174 ms
197,952 KB |
testcase_23 | AC | 1,142 ms
195,324 KB |
testcase_24 | AC | 1,087 ms
193,180 KB |
testcase_25 | AC | 1,139 ms
195,504 KB |
testcase_26 | AC | 1,175 ms
195,428 KB |
testcase_27 | AC | 979 ms
178,136 KB |
testcase_28 | AC | 981 ms
180,340 KB |
testcase_29 | AC | 980 ms
180,232 KB |
ソースコード
import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): from math import sin,cos,pi PI=pi 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) def ch(X): return (X*PI)/180 def func(a,b): [x1,y1],t1 = a [x2,y2],t2 = b x=x1 + x2*cos(t1) - y2*sin(t1) y=y1 + x2*sin(t1) + y2*cos(t1) th=(t1+t2) # print("a:",a," b:",b) # print([[x,y],th*180/PI]) return [[x,y],th] N,Q=MI() A=[[[1,0],0]for _ in range(N)] seg=SegmentTree(A, func, [[0,0],0]) ds=[1]*N ths=[0]*N for _ in range(Q): q=LI() if q[0]==0: i=q[1]-1 th=ch(q[2]) ths[i]=th dn=ds[i] v=[dn*cos(th),dn*sin(th)] seg.update(i,[v,th]) elif q[0]==1: i=q[1]-1 d=q[2] ds[i]=d thn=ths[i] v=[d*cos(thn), d*sin(thn)] seg.update(i,[v,thn]) else: #print("++++++++++++++") i=q[1]-1 vn,tn=seg.get_segment(0,i+1) print(*vn) # for i in range(N): # vn,thn=seg.query(i,i+1) # print(vn,thn*180/PI) main()