結果
問題 | No.1226 I hate Robot Arms |
ユーザー | tokusakurai |
提出日時 | 2020-09-11 22:59:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 329 ms / 2,000 ms |
コード長 | 4,124 bytes |
コンパイル時間 | 2,657 ms |
コンパイル使用メモリ | 211,424 KB |
実行使用メモリ | 13,532 KB |
最終ジャッジ日時 | 2024-06-10 10:36:31 |
合計ジャッジ時間 | 12,073 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 92 ms
6,940 KB |
testcase_03 | AC | 98 ms
6,940 KB |
testcase_04 | AC | 108 ms
12,924 KB |
testcase_05 | AC | 93 ms
13,236 KB |
testcase_06 | AC | 258 ms
13,184 KB |
testcase_07 | AC | 79 ms
6,944 KB |
testcase_08 | AC | 28 ms
13,096 KB |
testcase_09 | AC | 188 ms
6,944 KB |
testcase_10 | AC | 22 ms
6,944 KB |
testcase_11 | AC | 125 ms
13,088 KB |
testcase_12 | AC | 66 ms
8,320 KB |
testcase_13 | AC | 48 ms
13,300 KB |
testcase_14 | AC | 216 ms
6,944 KB |
testcase_15 | AC | 18 ms
13,108 KB |
testcase_16 | AC | 273 ms
13,364 KB |
testcase_17 | AC | 79 ms
6,944 KB |
testcase_18 | AC | 45 ms
6,940 KB |
testcase_19 | AC | 130 ms
13,040 KB |
testcase_20 | AC | 112 ms
12,980 KB |
testcase_21 | AC | 159 ms
12,900 KB |
testcase_22 | AC | 256 ms
13,364 KB |
testcase_23 | AC | 252 ms
13,412 KB |
testcase_24 | AC | 258 ms
13,504 KB |
testcase_25 | AC | 255 ms
13,356 KB |
testcase_26 | AC | 249 ms
13,304 KB |
testcase_27 | AC | 293 ms
13,316 KB |
testcase_28 | AC | 295 ms
13,532 KB |
testcase_29 | AC | 329 ms
13,360 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define elif else if #define sp(x) fixed << setprecision(x) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() using ll = long long; using pii = pair<int, int>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pll = pair<ll, ll>; const ll MOD = 1000000007; //const ll MOD = 998244353; const int inf = (1<<30)-1; const ll INF = (1LL<<60)-1; const double pi = acos(-1.0); const double EPS = 1e-10; template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;}; template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;}; template<typename Monoid, typename Operator_Monoid> struct Lazy_Segment_Tree{ vector<Monoid> seg; vector<Operator_Monoid> lazy; const Monoid e1; const Operator_Monoid e2; const int n; Monoid f(const Monoid &a, const Monoid &b) const {return a+b;} Monoid g(const Monoid &a, const Operator_Monoid &b) const {return a*b;} Operator_Monoid h(const Operator_Monoid &a, const Operator_Monoid &b) const {return a*b;} Lazy_Segment_Tree(int N, const Monoid &e1, const Operator_Monoid &e2) : e1(e1), e2(e2), n(1<<(32-__builtin_clz(N-1))){ seg.assign(2*n, e1), lazy.assign(2*n, e2); } void set(int i, const Monoid &x) {seg[n+i] = x;} void build(){ rep3(i, n-1, 1) seg[i] = f(seg[2*i], seg[2*i+1]); } void init(int N, const Monoid &x){ rep(i, N) set(i, x); build(); } void eval(int i, int l, int r){ if(lazy[i] != e2){ //seg[i] = g(seg[i], lazy[i]*(r-l)); seg[i] = g(seg[i], lazy[i]); if(r-l > 1){ lazy[2*i] = h(lazy[2*i] ,lazy[i]); lazy[2*i+1] = h(lazy[2*i+1], lazy[i]); } lazy[i] = e2; } } void add(int a, int b, const Operator_Monoid &x, int i, int l, int r){ eval(i, l, r); if(a >= r || b <= l) return; if(a <= l && r <= b){ lazy[i] = h(lazy[i], x); eval(i, l, r); } else{ add(a, b, x, 2*i, l, (l+r)/2); add(a, b, x, 2*i+1, (l+r)/2, r); seg[i] = f(seg[2*i], seg[2*i+1]); } } void add(int a, int b, const Operator_Monoid &x) {add(a, b, x, 1, 0, n);} Monoid query(int a, int b, int i, int l, int r){ eval(i, l, r); if(a >= r || b <= l) return e1; if(a <= l && r <= b) return seg[i]; Monoid vl = query(a, b, 2*i, l, (l+r)/2); Monoid vr = query(a, b, 2*i+1, (l+r)/2, r); return f(vl, vr); } Monoid query(int a, int b) {return query(a, b, 1, 0, n);} void update(int i, int l, int r){ seg[i] = g(seg[i], lazy[i]); if(r-l > 1){ lazy[2*i] = h(lazy[2*i], lazy[i]); lazy[2*i+1] = h(lazy[2*i+1], lazy[i]); update(2*i, l, (l+r)/2); update(2*i+1, (l+r)/2, r); } lazy[i] = e2; } void update() {update(1, 0, n);} Monoid operator [] (int i) const {return seg[n+i];} void clear(){ fill(all(seg), e1), fill(all(lazy), e2); } }; int main(){ int N, Q; cin >> N >> Q; Lazy_Segment_Tree<complex<double>, complex<double>> seg(N, {0.0, 0.0}, {1.0, 0.0}); seg.init(N, {1.0, 0.0}); double t[N], d[N]; fill(t, t+N, 0.0), fill(d, d+N, 1.0); while(Q--){ int q, i; cin >> q >> i; if(q == 2){ complex<double> ans = seg.query(0, i); cout << sp(10) << real(ans) << ' ' << imag(ans) << endl; } else{ double x; cin >> x; if(q == 0){ seg.add(i-1, N, polar(1.0, (x-t[i-1])*pi/180.0)); t[i-1] = x; } else{ seg.add(i-1, i, {x/d[i-1], 0.0}); d[i-1] = x; } } } }