Submission #738853

#TimeUsernameProblemLanguageResultExecution timeMemory
738853Muaath_5Game (IOI13_game)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 1e9 + 1; int n, q; const ll OUT = 0; ll merge(ll t1, ll t2) { if (t1 == OUT) return t2; if (t2 == OUT) return t1; return gcd(t1, t2); } struct xnode { xnode* left = nullptr, * right = nullptr; ynode* yy = new ynode(); }; struct ynode { ll val = OUT; ynode* left = nullptr, * right = nullptr; inline void upd() { ll m1 = OUT, m2 = OUT; if (left) m1 = left->val; if (right) m2 = right->val; val = merge(m1, m2); } }; void update_y(int qy, ll val, ynode* node, int l = 0, int r = N - 1) { if (l == r) { node->val = val; return; } const int mid = (l + r) / 2; if (qy <= mid) { if (!node->left) node->left = new ynode(); update_y(qy, val, node->left, l, mid); } else { if (!node->right) node->right = new ynode(); update_y(qy, val, node->right, mid + 1, r); } node->upd(); } void update_x(int qx, int qy, ll val, xnode* node, int l = 0, int r = N - 1) { if (l != r) { const int mid = (l + r) / 2; if (qx <= mid) { if (!node->left) node->left = new xnode(); update_x(qx, qy, val, node->left, l, mid); } else { if (!node->right) node->right = new xnode(); update_x(qx, qy, val, node->right, mid + 1, r); } } update_y(qy, merge( (node->left && node->left->yy ? query_y(qy, qy, node->left->yy) : OUT), (node->right && node->right->yy ? query_y(qy, qy, node->right->yy) : OUT) ), node->yy); } ll query_y(int qy1, int qy2, ynode* node, int l = 0, int r = N - 1) { if (node == nullptr || r < qy1 || qy2 < l) return OUT; if (qy1 <= l && r <= qy2) return node->val; const int mid = (l + r) / 2; return merge( query_y(qy1, qy2, node->left, l, mid), query_y(qy1, qy2, node->right, mid + 1, r) ); } ll query_x(int qx1, int qy1, int qx2, int qy2, xnode* node, int l = 0, int r = N - 1) { if (node == nullptr || r < qx1 || qx2 < l) return OUT; if (qx1 <= l && r <= qx2) return query_y(qy1, qy2, node->yy); const int mid = (l + r) / 2; return merge( query_x(qx1, qy1, qx2, qy2, node->left, l, mid), query_x(qx1, qy1, qx2, qy2, node->right, mid + 1, r) ); } xnode* root; void init(int R, int C) {} void update(int x, int y, ll k) { update_x(x, y, k, root); } ll calculate(int x1, int y1, int x2, int y2) { return query_x(x1, y1, x2, y2, root); }

Compilation message (stderr)

game.cpp:18:5: error: 'ynode' does not name a type; did you mean 'xnode'?
   18 |     ynode* yy = new ynode();
      |     ^~~~~
      |     xnode
game.cpp: In function 'void update_x(int, int, long long int, xnode*, int, int)':
game.cpp:64:36: error: 'struct xnode' has no member named 'yy'
   64 |         (node->left && node->left->yy ? query_y(qy, qy, node->left->yy) : OUT),
      |                                    ^~
game.cpp:64:69: error: 'struct xnode' has no member named 'yy'
   64 |         (node->left && node->left->yy ? query_y(qy, qy, node->left->yy) : OUT),
      |                                                                     ^~
game.cpp:64:41: error: 'query_y' was not declared in this scope
   64 |         (node->left && node->left->yy ? query_y(qy, qy, node->left->yy) : OUT),
      |                                         ^~~~~~~
game.cpp:65:38: error: 'struct xnode' has no member named 'yy'
   65 |         (node->right && node->right->yy ? query_y(qy, qy, node->right->yy) : OUT)
      |                                      ^~
game.cpp:65:72: error: 'struct xnode' has no member named 'yy'
   65 |         (node->right && node->right->yy ? query_y(qy, qy, node->right->yy) : OUT)
      |                                                                        ^~
game.cpp:66:14: error: 'struct xnode' has no member named 'yy'
   66 |     ), node->yy);
      |              ^~
game.cpp: In function 'long long int query_x(int, int, int, int, xnode*, int, int)':
game.cpp:83:62: error: 'struct xnode' has no member named 'yy'
   83 |     if (qx1 <= l && r <= qx2) return query_y(qy1, qy2, node->yy);
      |                                                              ^~