#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; templateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} //end template struct LazySegmentTree{ using F=function; using G=function; using H=function; int sz,height; vector data; vector lazy; const F f;const G g; const H h; const M m1; const N n1; LazySegmentTree(int n,const F f,const G g,const H h,const M &m1,const N n1):f(f),g(g),h(h),m1(m1),n1(n1){ sz=1,height=0; while(sz v){ rep(i,0,v.size())data[i+sz]=v[i]; for(int k=sz-1;k>0;k--)data[k]=f(data[2*k],data[2*k+1]); } M ref(int k){return lazy[k]==n1?data[k]:g(data[k],lazy[k]);} void recalc(int k){while(k>>=1)data[k]=f(ref(2*k),ref(2*k+1));} void thrust(int k){for(int i=height;i>0;i--)eval(k>>i);} void eval(int k){ if(lazy[k]!=n1){ lazy[2*k]=h(lazy[2*k],lazy[k]); lazy[2*k+1]=h(lazy[2*k+1],lazy[k]); data[k]=ref(k); lazy[k]=n1; } } void update(int a,int b,N x){ thrust(a+=sz); thrust(b+=sz-1); for(int l=a,r=b+1;l>=1,r>>=1){ if(l&1)lazy[l]=h(lazy[l],x),++l; if(r&1)--r,lazy[r]=h(lazy[r],x); } recalc(a); recalc(b); } M query(int a,int b){ thrust(a+=sz); thrust(b+=sz-1); M L=m1,R=m1; for(int l=a,r=b+1;l>=1,r>>=1){ if(l&1)L=f(L,ref(l++)); if(r&1)R=f(ref(--r),R); } return f(L,R); } void update2(int a,double x){ thrust(a+=sz); data[a].first*=x; data[a].second*=x; recalc(a); } }; typedef pair P; int main(){ int n,q; cin>>n>>q; auto ff=[&](P a,P b){ return P(a.first+b.first,a.second+b.second); }; auto gg=[&](P a,int b){ double r=b*(M_PI/180.); return P(a.first*cos(r)-a.second*sin(r),a.first*sin(r)+a.second*cos(r)); }; auto hh=[&](int a,int b){return (a+b)%360;}; LazySegmentTree seg(n,ff,gg,hh,{0,0},0); vector len(n),rad(n); vector

tmp(n); rep(i,0,n){ tmp[i]={1,0}; len[i]=1; rad[i]=0; } seg.build(tmp); rep(i,0,q){ int t; cin>>t; if(t==0){ int a,x; cin>>a>>x; a--; int y=(x-rad[a]+360)%360; seg.update(a,n,y); rad[a]=x; } if(t==1){ int a,x; cin>>a>>x; a--; seg.update2(a,(double)(x/len[a])); len[a]=x; } if(t==2){ int a; cin>>a; auto [x,y]=seg.query(0,a); printf("%.12f %.12f\n",x,y); } } return 0; }