結果
問題 | No.1226 I hate Robot Arms |
ユーザー | heno239 |
提出日時 | 2020-09-11 22:18:29 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 931 ms / 2,000 ms |
コード長 | 5,131 bytes |
コンパイル時間 | 1,119 ms |
コンパイル使用メモリ | 121,696 KB |
実行使用メモリ | 19,792 KB |
最終ジャッジ日時 | 2024-06-10 10:21:27 |
合計ジャッジ時間 | 22,807 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
12,100 KB |
testcase_01 | AC | 6 ms
12,104 KB |
testcase_02 | AC | 271 ms
12,872 KB |
testcase_03 | AC | 315 ms
13,824 KB |
testcase_04 | AC | 395 ms
19,356 KB |
testcase_05 | AC | 383 ms
19,576 KB |
testcase_06 | AC | 865 ms
19,456 KB |
testcase_07 | AC | 252 ms
12,928 KB |
testcase_08 | AC | 150 ms
19,412 KB |
testcase_09 | AC | 587 ms
13,636 KB |
testcase_10 | AC | 70 ms
12,416 KB |
testcase_11 | AC | 443 ms
19,288 KB |
testcase_12 | AC | 240 ms
15,488 KB |
testcase_13 | AC | 243 ms
19,568 KB |
testcase_14 | AC | 688 ms
13,896 KB |
testcase_15 | AC | 132 ms
19,380 KB |
testcase_16 | AC | 846 ms
19,712 KB |
testcase_17 | AC | 231 ms
13,892 KB |
testcase_18 | AC | 164 ms
13,824 KB |
testcase_19 | AC | 454 ms
19,328 KB |
testcase_20 | AC | 412 ms
19,240 KB |
testcase_21 | AC | 554 ms
19,128 KB |
testcase_22 | AC | 931 ms
19,524 KB |
testcase_23 | AC | 883 ms
19,692 KB |
testcase_24 | AC | 875 ms
19,712 KB |
testcase_25 | AC | 894 ms
19,640 KB |
testcase_26 | AC | 907 ms
19,792 KB |
testcase_27 | AC | 884 ms
19,584 KB |
testcase_28 | AC | 894 ms
19,708 KB |
testcase_29 | AC | 889 ms
19,592 KB |
ソースコード
#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 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; }