結果

問題 No.1226 I hate Robot Arms
ユーザー carrot46carrot46
提出日時 2020-09-11 23:20:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,557 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 173,808 KB
実行使用メモリ 8,356 KB
最終ジャッジ日時 2023-08-30 10:34:01
合計ジャッジ時間 12,400 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    int 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, x, id;
        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(x);
            reps(j, id * sz, (id + 1) * sz) {
                elem[j].theta += group[id].theta;
                if(j == i) d -= elem[j].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;
        }
    }
}

0