結果

問題 No.1226 I hate Robot Arms
ユーザー 👑 kmjpkmjp
提出日時 2020-09-11 22:15:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 669 ms / 2,000 ms
コード長 1,941 bytes
コンパイル時間 3,110 ms
コンパイル使用メモリ 207,276 KB
実行使用メモリ 119,092 KB
最終ジャッジ日時 2023-08-30 09:57:37
合計ジャッジ時間 24,539 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 215 ms
118,228 KB
testcase_01 AC 217 ms
118,128 KB
testcase_02 AC 349 ms
118,044 KB
testcase_03 AC 375 ms
118,080 KB
testcase_04 AC 386 ms
118,712 KB
testcase_05 AC 366 ms
119,092 KB
testcase_06 AC 651 ms
118,876 KB
testcase_07 AC 336 ms
117,968 KB
testcase_08 AC 250 ms
119,008 KB
testcase_09 AC 510 ms
117,968 KB
testcase_10 AC 249 ms
117,968 KB
testcase_11 AC 411 ms
118,632 KB
testcase_12 AC 316 ms
118,688 KB
testcase_13 AC 287 ms
119,048 KB
testcase_14 AC 569 ms
117,920 KB
testcase_15 AC 234 ms
119,020 KB
testcase_16 AC 640 ms
118,996 KB
testcase_17 AC 321 ms
118,536 KB
testcase_18 AC 285 ms
118,480 KB
testcase_19 AC 412 ms
119,044 KB
testcase_20 AC 392 ms
118,852 KB
testcase_21 AC 479 ms
118,680 KB
testcase_22 AC 641 ms
118,948 KB
testcase_23 AC 655 ms
118,920 KB
testcase_24 AC 648 ms
118,960 KB
testcase_25 AC 647 ms
118,924 KB
testcase_26 AC 630 ms
118,900 KB
testcase_27 AC 650 ms
118,808 KB
testcase_28 AC 659 ms
118,836 KB
testcase_29 AC 669 ms
118,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


template<int NV> class SegTree_1 {
public:
	vector<vector<double>> V;
	vector<double> comp(vector<double> a,vector<double> b) {
		vector<double> c(3);
		c[2]=a[2]+b[2];
		c[0]=a[0]+b[0]*cos(a[2])-b[1]*sin(a[2]);
		c[1]=a[1]+b[0]*sin(a[2])+b[1]*cos(a[2]);
		return c;
		
	}
	
	SegTree_1(){
		V.resize(NV*2);
		int i;
		for(i=NV;i<2*NV;i++) V[i]={1,0,0};
		for(i=NV-1;i>=1;i--) {
			V[i]=comp(V[2*i],V[2*i+1]);
		}
	};
	vector<double> getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
		if(r<=x || y<=l) return {0,0,0};
		if(x<=l && r<=y) return V[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void update(int entry, int L,int D) {
		entry += NV;
		V[entry][2]=D*2*atan(1)*4/360;
		V[entry][0]=L*cos(V[entry][2]);
		V[entry][1]=L*sin(V[entry][2]);
		while(entry>1) entry>>=1, V[entry]=comp(V[entry*2],V[entry*2+1]);
	}
};

int L[101010];
int D[101010];
SegTree_1<1<<20> st;
int N,Q;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	FOR(i,N) L[i]=1;
	while(Q--) {
		cin>>i;
		if(i==0||i==1) {
			cin>>x>>y;
			x--;
			if(i==0) D[x]=y;
			if(i==1) L[x]=y;
			st.update(x,L[x],D[x]);
		}
		else {
			cin>>x;
			auto a=st.getval(0,x);
			_P("%.12lf %12lf\n",a[0],a[1]);
		}
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0