結果

問題 No.1226 I hate Robot Arms
ユーザー ooaiu
提出日時 2024-12-13 14:35:29
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 1,492 bytes
コンパイル時間 3,379 ms
コンパイル使用メモリ 259,648 KB
実行使用メモリ 11,712 KB
最終ジャッジ日時 2024-12-13 14:35:46
合計ジャッジ時間 16,286 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef LOCAL
#include <bits/stdc++.h>

using namespace std;

#define debug(...) (void(0))
#else
#include "algo/debug.h"
#endif

using S = complex<double>;
S op(S a, S b) {
    return a + b;
}
S e() { return S{0, 0}; }
using F = S;
F id() { return F{1, 0}; }
F composition(F f, F g) {
    return f * g;
}
S mapping(F f, S x) {
    return x * f;
}
#include <atcoder/lazysegtree>
#include <atcoder/modint>
using deg = atcoder::static_modint<360>;

void solve() {
    int N, Q;
    cin >> N >> Q;
    vector<int> D(N, 1);
    vector<deg> T(N);
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(N, S{1, 0}));
    while (Q--) {
        int o;
        cin >> o;
        if (o == 0) {
            int p, x;
            cin >> p >> x;
            p--;
            deg y = x - T[p];
            double th = M_PI * y.val() / 180;
            seg.apply(p, N, F{cos(th), sin(th)});
            T[p] = deg::raw(x);
        } else if (o == 1) {
            int p, x;
            cin >> p >> x;
            p--;
            double y = double(x) / D[p];
            seg.set(p, seg.get(p) * y);
            D[p] = x;
        } else {
            int p;
            cin >> p;
            S ans = seg.prod(0, p);
            cout << fixed << setprecision(16) << ans.real() << " " << ans.imag() << '\n';
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int tt = 1;
    // std::cin >> tt;
    while (tt--) {
        solve();
    }
}
0