結果
問題 | No.1226 I hate Robot Arms |
ユーザー |
![]() |
提出日時 | 2020-09-11 22:10:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,136 bytes |
コンパイル時間 | 1,355 ms |
コンパイル使用メモリ | 120,656 KB |
実行使用メモリ | 27,420 KB |
最終ジャッジ日時 | 2025-01-01 21:07:57 |
合計ジャッジ時間 | 22,968 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 WA * 10 |
ソースコード
#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; }