結果
問題 | No.1226 I hate Robot Arms |
ユーザー | uni_python |
提出日時 | 2020-09-13 00:16:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,106 ms / 2,000 ms |
コード長 | 2,902 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 82,276 KB |
実行使用メモリ | 197,884 KB |
最終ジャッジ日時 | 2024-06-10 19:12:12 |
合計ジャッジ時間 | 26,731 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
53,120 KB |
testcase_01 | AC | 39 ms
54,656 KB |
testcase_02 | AC | 445 ms
100,472 KB |
testcase_03 | AC | 525 ms
112,628 KB |
testcase_04 | AC | 622 ms
147,520 KB |
testcase_05 | AC | 565 ms
148,332 KB |
testcase_06 | AC | 1,045 ms
192,592 KB |
testcase_07 | AC | 437 ms
100,700 KB |
testcase_08 | AC | 311 ms
125,324 KB |
testcase_09 | AC | 684 ms
125,404 KB |
testcase_10 | AC | 254 ms
85,632 KB |
testcase_11 | AC | 657 ms
148,636 KB |
testcase_12 | AC | 434 ms
115,132 KB |
testcase_13 | AC | 395 ms
134,712 KB |
testcase_14 | AC | 849 ms
137,300 KB |
testcase_15 | AC | 275 ms
123,504 KB |
testcase_16 | AC | 1,091 ms
191,984 KB |
testcase_17 | AC | 445 ms
106,724 KB |
testcase_18 | AC | 345 ms
100,348 KB |
testcase_19 | AC | 706 ms
153,864 KB |
testcase_20 | AC | 640 ms
146,772 KB |
testcase_21 | AC | 760 ms
158,896 KB |
testcase_22 | AC | 1,090 ms
197,884 KB |
testcase_23 | AC | 1,080 ms
195,380 KB |
testcase_24 | AC | 1,034 ms
192,596 KB |
testcase_25 | AC | 1,087 ms
195,484 KB |
testcase_26 | AC | 1,106 ms
194,964 KB |
testcase_27 | AC | 931 ms
178,016 KB |
testcase_28 | AC | 932 ms
180,004 KB |
testcase_29 | AC | 942 ms
180,164 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()