結果

問題 No.1226 I hate Robot Arms
ユーザー chocoruskchocorusk
提出日時 2020-09-11 21:39:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,405 bytes
コンパイル時間 1,597 ms
コンパイル使用メモリ 136,116 KB
実行使用メモリ 8,924 KB
最終ジャッジ日時 2023-08-30 09:44:17
合計ジャッジ時間 6,335 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template<typename Monoid>
struct SegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	int sz;
	vector<Monoid> seg;
	const F f;
	const Monoid e;

	SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
	}

	SegmentTree(int n, const F f, const Monoid &e, vector<Monoid> v): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
		for(int i=0; i<n; i++) seg[i+sz]=v[i];
		for(int i=sz-1; i>=1; i--){
			seg[i]=f(seg[2*i], seg[2*i+1]);
		}
	}

	void update(int k, const Monoid &x){
		k+=sz;
		seg[k]=x;
		while(k>1){
			k>>=1;
			seg[k]=f(seg[2*k], seg[2*k+1]);
		}
	}

	Monoid query(int a, int b){
		a+=sz, b+=sz;
		Monoid ret=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) ret=f(ret, seg[--b]);
			if(a&1) ret=f(ret, seg[a++]);
		}
		return ret;
	}

	/*Monoid query(int a, int b){ //演算が非可換のとき
		a+=sz, b+=sz;
		Monoid retl=e, retr=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) retr=f(seg[--b], retr);
			if(a&1) retl=f(retl, seg[a++]);
		}
		return f(retl, retr);
	}*/

	Monoid operator[](const int &k) const{
		return seg[k+sz];
	}
};
int main()
{
	int n, q;
	cin>>n>>q;
	vector<double> vx(n, 1);
	SegmentTree<double> segx(n, [](double a, double b){ return a+b;}, 0, vx);
	SegmentTree<double> segy(n, [](double a, double b){ return a+b;}, 0);
	int d[100010];
	fill(d, d+n, 1);
	int c[100010];
	fill(c, c+n, 0);
	const double PI=acos(-1.0);
	while(q--){
		int t;
		cin>>t;
		if(t==0){
			int i, x; cin>>i>>x;
			i--;
			c[i]=x;
			segx.update(i, d[i]*cos(PI/180.0*c[i]));
			segx.update(i, d[i]*cos(PI/180.0*c[i]));
		}else if(t==1){
			int i, x; cin>>i>>x;
			i--;
			d[i]=x;
			segx.update(i, d[i]*cos(PI/180.0*c[i]));
			segx.update(i, d[i]*cos(PI/180.0*c[i]));
		}else{
			int i; cin>>i;
			printf("%.7lf %.7lf\n", segx.query(0, i), segy.query(0, i));
		}
	}
	return 0;
}
0