結果

問題 No.1226 I hate Robot Arms
ユーザー heno239heno239
提出日時 2020-09-11 22:10:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,136 bytes
コンパイル時間 1,444 ms
コンパイル使用メモリ 123,636 KB
実行使用メモリ 27,376 KB
最終ジャッジ日時 2024-06-10 10:17:15
合計ジャッジ時間 25,139 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,100 KB
testcase_01 AC 6 ms
12,352 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 466 ms
26,620 KB
testcase_05 AC 452 ms
27,344 KB
testcase_06 WA -
testcase_07 AC 294 ms
13,764 KB
testcase_08 AC 184 ms
26,616 KB
testcase_09 AC 672 ms
15,556 KB
testcase_10 AC 80 ms
12,864 KB
testcase_11 WA -
testcase_12 AC 275 ms
19,320 KB
testcase_13 AC 287 ms
27,364 KB
testcase_14 WA -
testcase_15 AC 162 ms
27,088 KB
testcase_16 AC 994 ms
27,180 KB
testcase_17 AC 275 ms
15,940 KB
testcase_18 AC 194 ms
16,068 KB
testcase_19 AC 529 ms
26,736 KB
testcase_20 WA -
testcase_21 AC 648 ms
26,244 KB
testcase_22 WA -
testcase_23 AC 1,035 ms
27,336 KB
testcase_24 AC 1,040 ms
27,196 KB
testcase_25 AC 1,045 ms
27,260 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1,033 ms
27,264 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
//#include<atcoder/dsu>
//#include<atcoder/fenwicktree>
//#include<atcoder/math>
//#include<atcoder/maxflow>

using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	if (x >= m)x %= m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	while (b) {
		int r = a % b; a = b; b = r;
	}
	return a;
}
template<typename T>
struct SegT {
private:
	int sz; vector<T> node;
	T init_c;
	function<T(T, T)> f;
public:
	SegT(vector<T> v, T _init_c, function<T(T, T)> _f) {
		init_c = _init_c; f = _f;
		int n = v.size();
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
		rep(i, n) {
			node[i + sz - 1] = v[i];
		}
		per(i, sz - 1) {
			node[i] = f(node[2 * i + 1], node[2 * i + 2]);
		}
	}
	SegT(int n, T _init_c, function<T(T, T)> _f) {
		init_c = _init_c; f = _f;
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
	}
	void update(int k, T a) {
		k += sz - 1;
		node[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = f(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	T query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = sz;
		if (r <= a || b <= l)return init_c;
		else if (a <= l && r <= b)return node[k];
		else {
			T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}
};


struct ste {
	ld d, t,st;
};
void solve() {
	int n, q; cin >> n >> q;
	auto f = [&](ste a, ste b)->ste {
		if (a.d == 0)return b;
		if (b.d == 0)return a;
		ld d, t,st;
		st = a.st + b.st;
		ld x = a.d * cosl(a.t);
		ld y = a.d * sinl(a.t);
		ld nx = x + b.d * cosl(a.st+b.t);
		ld ny = y + b.d * sinl(a.st+b.t);
		d = sqrtl(nx * nx + ny * ny);
		t = atan2l(ny, nx);
		return { d,t,st };
	};
	SegT<ste> st(n, { 0,0,0 }, f);
	rep(i, n)st.update(i, { 1,0,0});
	/*rep1(i, 3) {
		LDP p = st.query(0, i);
		ld x = p.first * cosl(p.second);
		ld y = p.first * sinl(p.second);
		cout << x << " " << y << "\n";
	}*/
	vector<ld> ls(n, 1), args(n, 0);
	rep(i, q) {
		int t; cin >> t;
		if (t == 0) {
			int v; cin >> v; v--;
			ld x; cin >> x; x *= pi / 180.0;
			args[v] = x;
			st.update(v, { ls[v],args[v],args[v] });
		}
		else if (t == 1) {
			int v; cin >> v; v--;
			ld x; cin >> x; ls[v] = x;
			st.update(v, { ls[v],args[v],args[v] });

		}
		else {
			int v; cin >> v;
			ste p = st.query(0, v);
			//cout << "? " << p.first << " " << p.second << "\n";
			ld x = p.d * cosl(p.t);
			ld y = p.d * sinl(p.t);
			cout << x << " " << y << "\n";
		}
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	//init_f();
	//init();
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}
0