結果
問題 | No.1226 I hate Robot Arms |
ユーザー | KKT89 |
提出日時 | 2022-04-30 05:33:19 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 294 ms / 2,000 ms |
コード長 | 3,815 bytes |
コンパイル時間 | 1,706 ms |
コンパイル使用メモリ | 135,296 KB |
実行使用メモリ | 12,788 KB |
最終ジャッジ日時 | 2023-09-11 22:00:26 |
合計ジャッジ時間 | 11,385 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 3 ms
4,376 KB |
testcase_02 | AC | 74 ms
4,380 KB |
testcase_03 | AC | 89 ms
5,140 KB |
testcase_04 | AC | 130 ms
10,384 KB |
testcase_05 | AC | 138 ms
12,072 KB |
testcase_06 | AC | 260 ms
11,800 KB |
testcase_07 | AC | 70 ms
4,420 KB |
testcase_08 | AC | 66 ms
10,296 KB |
testcase_09 | AC | 158 ms
5,192 KB |
testcase_10 | AC | 20 ms
4,376 KB |
testcase_11 | AC | 139 ms
9,840 KB |
testcase_12 | AC | 73 ms
6,684 KB |
testcase_13 | AC | 95 ms
12,324 KB |
testcase_14 | AC | 190 ms
5,404 KB |
testcase_15 | AC | 61 ms
10,964 KB |
testcase_16 | AC | 260 ms
12,072 KB |
testcase_17 | AC | 73 ms
5,948 KB |
testcase_18 | AC | 53 ms
6,092 KB |
testcase_19 | AC | 148 ms
10,888 KB |
testcase_20 | AC | 132 ms
9,912 KB |
testcase_21 | AC | 164 ms
9,284 KB |
testcase_22 | AC | 282 ms
12,472 KB |
testcase_23 | AC | 272 ms
12,524 KB |
testcase_24 | AC | 272 ms
12,348 KB |
testcase_25 | AC | 271 ms
12,276 KB |
testcase_26 | AC | 274 ms
12,412 KB |
testcase_27 | AC | 290 ms
12,788 KB |
testcase_28 | AC | 294 ms
12,324 KB |
testcase_29 | AC | 293 ms
12,664 KB |
ソースコード
#pragma GCC optimize("Ofast") #include <iostream> #include <vector> #include <algorithm> #include <map> #include <queue> #include <cstdio> #include <ctime> #include <assert.h> #include <chrono> #include <random> #include <numeric> #include <set> #include <deque> #include <stack> #include <sstream> #include <utility> #include <cstring> #include <unordered_map> #include <unordered_set> #include <tuple> #include <array> #include <bitset> using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } struct point{ long double x,y; point() {} point(long double x,long double y): x(x), y(y) {} point& operator-=(const point &p){ x -= p.x; y -= p.y; return *this; } point& operator+=(const point &p){ x += p.x; y += p.y; return *this; } point& operator*=(long double d){ x *= d; y *= d; return *this; } point& operator/=(long double d){ x /= d; y /= d; return *this; } const point operator+ (const point& p) const; const point operator- (const point& p) const; const point operator* (long double d) const; const point operator/ (long double d) const; }; const point point::operator+ (const point& p) const{ point res(*this); return res += p; } const point point::operator- (const point& p) const{ point res(*this); return res -= p; } const point point::operator* (long double d) const{ point res(*this); return res *= d; } const point point::operator/ (long double d) const{ point res(*this); return res /= d; } long double abs(point P){ return sqrt(P.x*P.x+P.y*P.y); } template <class S, S (*op)(S, S), S (*e)()> struct segtree { int n; vector<S> tree; segtree() : segtree(0) {} segtree(int n) : n(n), tree(vector<S>(n<<1, e())) {} void update(int k) { tree[k] = op(tree[k<<1|0], tree[k<<1|1]); } S operator[](int i) {return tree[i+n]; } void set(int i, S x) { i += n; tree[i] = x; while(i >>= 1) { update(i); } } // [l,r) S query(int l, int r) { S sml = e(), smr = e(); for(l += n, r += n; l < r; l >>= 1, r >>= 1){ if(l & 1) sml = op(sml, tree[l++]); if(r & 1) smr = op(tree[--r], smr); } return op(sml,smr); } }; // ベクトルと回転角度を持つ using P = pair<point,long double>; P op(P a,P b){ auto p = a.first; auto pp = b.first; p += point(pp.x*cos(a.second)-pp.y*sin(a.second), pp.x*sin(a.second)+pp.y*cos(a.second)); return {p, a.second+b.second}; } P e() {return {{0,0},0};}; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n,q; cin >> n >> q; segtree<P,op,e> seg(n); for(int i=0;i<n;i++){ seg.set(i, {{1,0},0}); } while(q--){ int type; cin >> type; int i; cin >> i; i--; auto P = seg[i]; auto &p = P.first; if(type == 1){ int w; cin >> w; p = p / abs(p) * w; seg.set(i, P); } else if(type == 0){ int w; cin >> w; long double theta = acos(-1.0L) * (w) / 180.0; p = {p.x*cos(-P.second+theta)-p.y*sin(-P.second+theta), p.x*sin(-P.second+theta)+p.y*cos(-P.second+theta)}; P.second = theta; seg.set(i, P); } else{ auto res = seg.query(0, i+1); double x = res.first.x, y = res.first.y; printf("%.9f %.9f\n",x, y); } } }