#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 1000000007; // constexpr int MOD = 998244353; constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; template struct SegmentTree { SegmentTree(int sz, Fn fn, const Monoid UNITY) : fn(fn), UNITY(UNITY) { init(sz); dat.assign(n << 1, UNITY); } SegmentTree(const std::vector &a, Fn fn, const Monoid UNITY) : fn(fn), UNITY(UNITY) { int a_sz = a.size(); init(a_sz); dat.resize(n << 1); for (int i = 0; i < a_sz; ++i) dat[i + n] = a[i]; for (int i = n - 1; i > 0; --i) dat[i] = fn(dat[i << 1], dat[(i << 1) + 1]); } void update(int node, Monoid val) { node += n; dat[node] = val; while (node >>= 1) dat[node] = fn(dat[node << 1], dat[(node << 1) + 1]); } Monoid query(int left, int right) const { Monoid l_res = UNITY, r_res = UNITY; for (left += n, right += n; left < right; left >>= 1, right >>= 1) { if (left & 1) l_res = fn(l_res, dat[left++]); if (right & 1) r_res = fn(dat[--right], r_res); } return fn(l_res, r_res); } Monoid operator[](const int idx) const { return dat[idx + n]; } private: int n = 1; Fn fn; const Monoid UNITY; std::vector dat; void init(int sz) { while (n < sz) n <<= 1; } }; int main() { struct Node { double x, y, angle; }; auto fn = [](Node a, Node b) { double x = a.x + cos(a.angle) * b.x - sin(a.angle) * b.y; double y = a.y + sin(a.angle) * b.x + cos(a.angle) * b.y; return Node{x, y, a.angle + b.angle}; }; int n, q; cin >> n >> q; vector angle(n, 0), len(n, 1); SegmentTree seg(n, fn, Node{0, 0, 0}); REP(i, n) seg.update(i, Node{1, 0, 0}); while (q--) { int query, i; cin >> query >> i; --i; if (query == 0) { int x; cin >> x; angle[i] = x; seg.update(i, Node{len[i] * cos(x * M_PI / 180), len[i] * sin(x * M_PI / 180), x * M_PI / 180}); } else if (query == 1) { int x; cin >> x; len[i] = x; seg.update(i, Node{x * cos(angle[i] * M_PI / 180), x * sin(angle[i] * M_PI / 180), angle[i] * M_PI / 180}); } else if (query == 2) { Node ans = seg.query(0, i + 1); cout << ans.x << ' ' << ans.y << '\n'; } } return 0; }