結果
問題 | No.1226 I hate Robot Arms |
ユーザー | beet |
提出日時 | 2020-09-11 22:46:15 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 238 ms / 2,000 ms |
コード長 | 3,155 bytes |
コンパイル時間 | 2,873 ms |
コンパイル使用メモリ | 206,172 KB |
実行使用メモリ | 14,472 KB |
最終ジャッジ日時 | 2023-08-30 10:12:07 |
合計ジャッジ時間 | 14,259 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 67 ms
4,776 KB |
testcase_03 | AC | 75 ms
5,936 KB |
testcase_04 | AC | 83 ms
13,864 KB |
testcase_05 | AC | 76 ms
14,120 KB |
testcase_06 | AC | 196 ms
14,440 KB |
testcase_07 | AC | 60 ms
4,676 KB |
testcase_08 | AC | 25 ms
13,632 KB |
testcase_09 | AC | 140 ms
5,888 KB |
testcase_10 | AC | 17 ms
4,376 KB |
testcase_11 | AC | 98 ms
13,432 KB |
testcase_12 | AC | 52 ms
8,752 KB |
testcase_13 | AC | 42 ms
14,128 KB |
testcase_14 | AC | 169 ms
5,916 KB |
testcase_15 | AC | 16 ms
13,856 KB |
testcase_16 | AC | 193 ms
14,272 KB |
testcase_17 | AC | 54 ms
5,880 KB |
testcase_18 | AC | 38 ms
6,308 KB |
testcase_19 | AC | 98 ms
13,856 KB |
testcase_20 | AC | 93 ms
13,664 KB |
testcase_21 | AC | 125 ms
13,540 KB |
testcase_22 | AC | 208 ms
14,396 KB |
testcase_23 | AC | 208 ms
14,304 KB |
testcase_24 | AC | 204 ms
14,432 KB |
testcase_25 | AC | 203 ms
14,452 KB |
testcase_26 | AC | 200 ms
14,388 KB |
testcase_27 | AC | 233 ms
14,308 KB |
testcase_28 | AC | 238 ms
14,316 KB |
testcase_29 | AC | 238 ms
14,472 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using Int = long long; const char newl = '\n'; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);} template<typename T=int> vector<T> read(size_t n){ vector<T> ts(n); for(size_t i=0;i<n;i++) cin>>ts[i]; return ts; } template <typename T> struct SegmentTree{ using F = function<T(T,T)>; int n; F f; T ti; vector<T> dat; SegmentTree(){} SegmentTree(F f,T ti):f(f),ti(ti){} void init(int n_){ n=1; while(n<n_) n<<=1; dat.assign(n<<1,ti); } void build(const vector<T> &v){ int n_=v.size(); init(n_); for(int i=0;i<n_;i++) dat[n+i]=v[i]; for(int i=n-1;i;i--) dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]); } void set_val(int k,T x){ dat[k+=n]=x; while(k>>=1) dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]); } T query(int a,int b){ if(a>=b) return ti; T vl=ti,vr=ti; for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) { if(l&1) vl=f(vl,dat[l++]); if(r&1) vr=f(dat[--r],vr); } return f(vl,vr); } template<typename C> int find(int st,C &check,T &acc,int k,int l,int r){ if(l+1==r){ acc=f(acc,dat[k]); return check(acc)?k-n:-1; } int m=(l+r)>>1; if(m<=st) return find(st,check,acc,(k<<1)|1,m,r); if(st<=l&&!check(f(acc,dat[k]))){ acc=f(acc,dat[k]); return -1; } int vl=find(st,check,acc,(k<<1)|0,l,m); if(~vl) return vl; return find(st,check,acc,(k<<1)|1,m,r); } template<typename C> int find(int st,C &check){ T acc=ti; return find(st,check,acc,1,0,n); } }; struct Precision{ Precision(){ cout<<fixed<<setprecision(12); } }precision_beet; //INSERT ABOVE HERE signed main(){ cin.tie(0); ios::sync_with_stdio(0); using D = double; struct T{ D x,y,theta,sum; T(D x,D y,D theta,D sum):x(x),y(y),theta(theta),sum(sum){} }; T ti(0,0,-1,0); auto f=[&](T a,T b){ if(a.theta<0) return b; D th=a.sum+b.theta; D nx=a.x+(cos(th)*b.x-sin(th)*b.y); D ny=a.y+(sin(th)*b.x+cos(th)*b.y); return T(nx,ny,a.theta,a.sum+b.theta+b.sum); }; SegmentTree<T> seg(f,ti); int n,q; cin>>n>>q; vector<T> vt(n,T(1,0,0,0)); seg.build(vt); const D pi = asin(1) * 2; auto print=[&](T res){ // cout<<":"<<res.x<<' '<<res.y<<' '<<res.theta<<endl; cout<<cos(res.theta)*res.x-sin(res.theta)*res.y<<' '; cout<<sin(res.theta)*res.x+cos(res.theta)*res.y<<newl; }; for(int j=0;j<q;j++){ int t; cin>>t; if(t==0){ int i,x; cin>>i>>x; i--; vt[i].theta=x*pi/180.0; seg.set_val(i,vt[i]); } if(t==1){ int i,x; cin>>i>>x; i--; D len=hypot(vt[i].x,vt[i].y); vt[i].x*=x/len; vt[i].y*=x/len; seg.set_val(i,vt[i]); } if(t==2){ int i; cin>>i; print(seg.query(0,i)); } } // print(f(vt[0],vt[1])); // print(vt[2]); // cout<<f(vt[1],vt[2]).theta<<endl; // print(f(vt[0],f(vt[1],vt[2]))); return 0; }