結果

問題 No.1226 I hate Robot Arms
ユーザー uni_pythonuni_python
提出日時 2020-09-13 00:19:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,603 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 199,220 KB
最終ジャッジ日時 2023-08-30 19:39:48
合計ジャッジ時間 25,331 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 Segtree:
        def __init__(self, A, ide_ele, initialize = True, segf = max):
            self.N = len(A)
            self.N0 = 2**(self.N-1).bit_length()
            self.ide_ele = ide_ele
            self.segf = segf
            if initialize:
                self.data = [ide_ele]*self.N0 + A + [ide_ele]*(self.N0 - self.N)
                for i in range(self.N0-1, 0, -1):
                    self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) 
            else:
                self.data = [ide_ele]*(2*self.N0)

        def update(self, k, x):
            k += self.N0
            self.data[k] = x
            while k > 0 :
                k = k >> 1
                self.data[k] = self.segf(self.data[2*k], self.data[2*k+1])

        def query(self, l, r):
            L, R = l+self.N0, r+self.N0
            s = self.ide_ele
            while L < R:
                if L & 1:
                    s = self.segf(s, self.data[L])
                    L += 1
                if R & 1:
                    R -= 1
                    s = self.segf(s, self.data[R])
                L >>= 1
                R >>= 1
            return s
        
    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=Segtree(A, [[0,0],0], segf=func)
    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.query(0,i+1)
            # print("++++",i,*vn,tn*180/PI,"++++")
            print(*vn)
            

            
    # for i in range(N):
    #     vn,thn=seg.query(i,i+1)
    #     print(vn,thn*180/PI)
            
            
                
            
        

main()
0