結果
問題 | No.1226 I hate Robot Arms |
ユーザー | carrot46 |
提出日時 | 2020-09-11 23:43:50 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 622 ms / 2,000 ms |
コード長 | 4,619 bytes |
コンパイル時間 | 1,635 ms |
コンパイル使用メモリ | 173,416 KB |
実行使用メモリ | 8,268 KB |
最終ジャッジ日時 | 2023-08-30 10:40:50 |
合計ジャッジ時間 | 17,563 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
7,828 KB |
testcase_01 | AC | 4 ms
8,168 KB |
testcase_02 | AC | 189 ms
7,816 KB |
testcase_03 | AC | 207 ms
7,744 KB |
testcase_04 | AC | 207 ms
7,852 KB |
testcase_05 | AC | 180 ms
7,868 KB |
testcase_06 | AC | 493 ms
7,768 KB |
testcase_07 | AC | 170 ms
7,796 KB |
testcase_08 | AC | 45 ms
7,748 KB |
testcase_09 | AC | 388 ms
7,644 KB |
testcase_10 | AC | 48 ms
7,828 KB |
testcase_11 | AC | 233 ms
7,764 KB |
testcase_12 | AC | 131 ms
7,652 KB |
testcase_13 | AC | 89 ms
7,964 KB |
testcase_14 | AC | 469 ms
8,196 KB |
testcase_15 | AC | 25 ms
7,792 KB |
testcase_16 | AC | 499 ms
7,672 KB |
testcase_17 | AC | 141 ms
7,696 KB |
testcase_18 | AC | 93 ms
7,996 KB |
testcase_19 | AC | 240 ms
7,692 KB |
testcase_20 | AC | 216 ms
7,692 KB |
testcase_21 | AC | 303 ms
8,268 KB |
testcase_22 | AC | 502 ms
7,764 KB |
testcase_23 | AC | 506 ms
7,652 KB |
testcase_24 | AC | 509 ms
7,964 KB |
testcase_25 | AC | 514 ms
7,644 KB |
testcase_26 | AC | 502 ms
7,792 KB |
testcase_27 | AC | 615 ms
8,140 KB |
testcase_28 | AC | 622 ms
7,644 KB |
testcase_29 | AC | 612 ms
7,668 KB |
ソースコード
#include <bits/stdc++.h> //#include <chrono> //#pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() #define fi first #define se second typedef long long ll; typedef vector<ll> vec; typedef vector<vec> mat; ll N,M,H,W,Q,K,A,B; string S; typedef pair<ll, ll> P; const ll INF = (1LL<<60); template <unsigned long long mod > class modint{ public: ll x; modint(){x = 0;} modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){} modint operator-(){ return x == 0 ? 0 : mod - x; } modint& operator+=(const modint& a){ if((x += a.x) >= mod) x -= mod; return *this; } modint operator+(const modint& a) const{ return modint(*this) += a; } modint& operator-=(const modint& a){ if((x -= a.x) < 0) x += mod; return *this; } modint operator-(const modint& a) const{ return modint(*this) -= a; } modint& operator*=(const modint& a){ (x *= a.x)%=mod; return *this; } modint operator*(const modint& a) const{ return modint(*this) *= a; } modint pow(unsigned long long pw) const{ modint res(1), comp(*this); while(pw){ if(pw&1) res *= comp; comp *= comp; pw >>= 1; } return res; } //以下、modが素数のときのみ modint inv() const{ return modint(*this).pow(mod - 2); } modint& operator/=(const modint &a){ (x *= a.inv().x)%=mod; return *this; } modint operator/(const modint &a) const{ return modint(*this) /= a; } }; using mint = modint<360>; ostream& operator<<(ostream& os, const mint& a){ os << a.x; return os; } using vm = vector<mint>; using Pd = pair<long double, long double>; vector<long double> my_cos(360), my_sin(360); struct arm{ //groupではlazy, elemでは真値 mint theta; ll len; //elemのみ Pd v; arm() : theta(0), len(1), v(1, 0) {} arm(int l) : theta(0), len(l) {v = make_pair(l, 0);} void set_v(){ v = make_pair(my_cos[theta.x] * len, my_sin[theta.x] * len); } arm &operator += (const arm &a){ v.fi += a.v.fi; v.se += a.v.se; return *this; } const arm operator + (const arm &a){ return arm(*this) += a; } }; int main() { cin>>N>>Q; const int sz = 317, num = 317; vector<arm> group(num, arm(sz)), elem(num * sz, arm()); const long double pi = acos(-1); rep(i, 360){ long double phi = pi * i / 180; my_cos[i] = cos(phi); my_sin[i] = sin(phi); } rep(_, Q){ int i, id; ll x; cin>>A>>i; --i; id = i / sz; if(A == 1){ cin>>x; if(group[id].theta.x != 0){ reps(j, id * sz, (id + 1) * sz) { elem[j].theta += group[id].theta; elem[j].set_v(); } } elem[i].len = x; elem[i].set_v(); group[id] = accumulate(elem.begin() + id * sz, elem.begin() + (id + 1) * sz, arm(0)); }else if(A == 0){ cin>>x; mint d = (i ? elem[i-1].theta + group[(i - 1) / sz].theta : mint(0)) + x - (elem[i].theta + group[id].theta); reps(j, id * sz, (id + 1) * sz) { elem[j].theta += group[id].theta; if(j >= i) elem[j].theta += d; elem[j].set_v(); } group[id] = accumulate(elem.begin() + id * sz, elem.begin() + (id + 1) * sz, arm(0)); reps(j, id + 1, num) group[j].theta += d; }else{ Pd res(0, 0); rep(j, id) { int temp = group[j].theta.x; Pd &p = group[j].v; res.fi += p.fi * my_cos[temp] - p.se * my_sin[temp]; res.se += p.fi * my_sin[temp] + p.se * my_cos[temp]; } reps(j, id * sz, (id + 1) * sz) { elem[j].theta += group[id].theta; elem[j].set_v(); if(j <= i) { res.fi += elem[j].v.fi; res.se += elem[j].v.se; } } group[id] = accumulate(elem.begin() + id * sz, elem.begin() + (id + 1) * sz, arm(0)); cout<<fixed<<setprecision(10)<<res.fi<<' '<<res.se<<endl; } } }