Submission #738860

#TimeUsernameProblemLanguageResultExecution timeMemory
738860Muaath_5Game (IOI13_game)C++17
Compilation error
0 ms0 KiB
#include "game.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 1e9 + 1 const ll OUT = 0; ll merge(ll t1, ll t2) { return gcd(t1, t2); } 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); } }; struct xnode { xnode* left = nullptr, * right = nullptr; ynode* yy = new ynode(); }; 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) ); } 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); } xnode* root; void init(int R, int C) { root = new xnode(); } 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:8:1: error: expected ',' or ';' before 'const'
    8 | const ll OUT = 0;
      | ^~~~~
game.cpp:14:14: error: 'OUT' was not declared in this scope
   14 |     ll val = OUT;
      |              ^~~
game.cpp: In member function 'void ynode::upd()':
game.cpp:17:17: error: 'OUT' was not declared in this scope
   17 |         ll m1 = OUT, m2 = OUT;
      |                 ^~~
game.cpp:19:20: error: 'm2' was not declared in this scope; did you mean 'm1'?
   19 |         if (right) m2 = right->val;
      |                    ^~
      |                    m1
game.cpp:20:25: error: 'm2' was not declared in this scope; did you mean 'm1'?
   20 |         val = merge(m1, m2);
      |                         ^~
      |                         m1
game.cpp: In function 'long long int query_y(int, int, ynode*, int, int)':
game.cpp:31:55: error: 'OUT' was not declared in this scope
   31 |     if (node == nullptr || r < qy1 || qy2 < l) return OUT;
      |                                                       ^~~
game.cpp: In function 'long long int query_x(int, int, int, int, xnode*, int, int)':
game.cpp:42:55: error: 'OUT' was not declared in this scope
   42 |     if (node == nullptr || r < qx1 || qx2 < l) return OUT;
      |                                                       ^~~
game.cpp: In function 'void update_x(int, int, long long int, xnode*, int, int)':
game.cpp:84:75: error: 'OUT' was not declared in this scope
   84 |         (node->left && node->left->yy ? query_y(qy, qy, node->left->yy) : OUT),
      |                                                                           ^~~