Submission #738859

#TimeUsernameProblemLanguageResultExecution timeMemory
738859Muaath_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) { 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)

/usr/bin/ld: /tmp/ccGbFmoj.o: in function `main':
grader.c:(.text.startup+0x6b): undefined reference to `init'
/usr/bin/ld: grader.c:(.text.startup+0xd0): undefined reference to `calculate'
/usr/bin/ld: grader.c:(.text.startup+0x13e): undefined reference to `update'
collect2: error: ld returned 1 exit status