#include using namespace std; using ll = long long; using P = pair; constexpr char newl = '\n'; constexpr double PI = 3.14159265358979; // [Related]: monoid template struct SegmentTree { using T = typename Monoid::T; int n; vector data; vector ang; SegmentTree() {} SegmentTree(int size, T initial_value = Monoid::unit()) { n = 1; while (n < size) n <<= 1; data.assign(2 * n - 1, initial_value); ang.assign(2 * n - 1, 0); if (initial_value != Monoid::unit()) { for (int i = n - 2; i >= 0; i--) data[i] = Monoid::merge(data[i * 2 + 1], data[i * 2 + 2], ang[i * 2 + 2]); } } SegmentTree(const vector& v) { int size = v.size(); n = 1; while (n < size) n <<= 1; data.assign(2 * n - 1, Monoid::unit()); ang.assign(2 * n - 1, 0); for (int i = 0; i < size; i++) data[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) data[i] = Monoid::merge(data[i * 2 + 1], data[i * 2 + 2], ang[i]); } T getLeaf(int k) { return data[k + n - 1]; } void change(int s, T x, int v, int l, int r) { if (s <= l) return; else if (s < r) { int chl = (v << 1) + 1, chr = (v << 1) + 2; int m = (l + r) >> 1; change(s, x, chl, l, m); change(s, x, chr, m, r); if (s <= m) ang[v] += x.second; data[v] = Monoid::merge(data[chl], data[chr], ang[v]); } } void update(int k, T x) { if (x.first == 0) { change(k, x, 0, 0, n); return; } k += n - 1; Monoid::update(data[k], x); while (k > 0) { k = (k - 1) / 2; data[k] = Monoid::merge(data[2 * k + 1], data[2 * k + 2], ang[k]); } } //区間[a, b)に対するクエリに答える //k:節点番号, [l, r):節点に対応する区間 T query(int a, int b, int k, int l, int r) { //[a, b)と[l, r)が交差しない場合 if (r <= a || b <= l) return Monoid::unit(); //[a, b)が[l, r)を含む場合、節点の値 if (a <= l && r <= b) return data[k]; else { //二つの子をマージ T vl = query(a, b, k * 2 + 1, l, (l + r) / 2); T vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return Monoid::merge(vl, vr, ang[k]); } } //外から呼ぶ用 T query(int a, int b) { return query(a, b, 0, 0, n); } }; template struct Arm { using T = U; static T merge(const T& x, const T& y, double ang) { double s = sin(ang * PI / 180), c = cos(ang * PI / 180); return T( x.first + (c * y.first - s * y.second), x.second + (s * y.first + c * y.second) ); } static void update(T& target, const T& x) { target.first += x.first; } static constexpr T unit() { return T(0, 0); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, q; cin >> n >> q; vector d(n + 1, 1); vector th(n + 1, 0); vector

v(n + 1, P(1, 0)); v[0] = P(0, 0); SegmentTree< Arm<> > st(v); for (int i = 0; i < q; i++) { int com; cin >> com; if (com == 0) { int tar, x; cin >> tar >> x; double th_diff = (x - th[tar]); st.update(tar, P(0, th_diff)); th[tar] = x; } else if (com == 1) { int tar, x; cin >> tar >> x; double len_diff = x - d[tar]; st.update(tar, P(len_diff, 0)); d[tar] = x; } else { int tar; cin >> tar; P ans = st.query(0, tar + 1); cout << fixed << setprecision(20) << ans.first << " " << ans.second << newl; } } return 0; }