Submission #367637

#TimeUsernameProblemLanguageResultExecution timeMemory
367637idk321Game (IOI13_game)C++11
Compilation error
0 ms0 KiB
#include "game.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; typedef long long ll; int R; int C; ll gcd(ll X, ll Y) { ll tmp; while (X != Y && Y != 0) { tmp = X; X = Y; Y = tmp % Y; } return X; } struct TreeRow { vector<ll> tree;; TreeRow() { tree.resize(4 * C); for (int i = 0; i < N; i++) tree[i] = 0; } void ins(int i, ll num, int a, int b, int node) { if (a == b) { tree[node] = num; return; } int mid = (a + b) / 2; if (i <= mid) ins(i, num, a, mid, node * 2); else ins(i, num, mid + 1, b, node * 2 + 1); tree[node] = gcd(tree[node * 2], tree[node * 2 + 1]); } ll getAt(int from, int to, int a, int b, int node) { if (from <= a && b <= to) { return tree[node]; } int mid = (a + b) / 2; ll res = 0; if (from <= mid) res = gcd(res, getAt(from, to, a, mid, node * 2)); if (to > mid) res = gcd(res, getAt(from, to, mid + 1, b, node * 2 + 1)); return res; } }; vector<TreeRow> tree; void ins(int x, int y, ll num, int a, int b, int node) { if (a == b) { tree[node].ins(y, num, 0, N - 1, 1); return; } int mid = (a + b) / 2; if (x <= mid) ins(x, y, num, a, mid, node * 2); else ins(x, y, num, mid + 1, b, node * 2 + 1); tree[node].ins(y, gcd(tree[node * 2].getAt(y, y, 0, N - 1, 1), tree[node * 2 + 1].getAt(y, y, 0, N - 1, 1)), 0, N - 1, 1); } ll getAt(int x1, int x2, int y1, int y2, int a, int b, int node) { if (x1 <= a && b <= x2) { return tree[node].getAt(y1, y2, 0, N - 1, 1); } int mid = (a + b) / 2; ll res = 0; if (x1 <= mid) res = gcd(res, getAt(x1, x2, y1, y2, a, mid, node * 2)); if (x2 > mid) res = gcd(res, getAt(x1, x2, y1, y2, mid + 1, b, node * 2 + 1)); return res; } void init(int r, int c) { R = r; C = c; tree.resize(4 * R); } void update(int P, int Q, ll K) { ins(P, Q, K, 0, N - 1, 1); } ll calculate(int P, int Q, int U, int V) { /* ... */ return getAt(P, U, Q, V, 0, N - 1, 1); }

Compilation message (stderr)

game.cpp: In constructor 'TreeRow::TreeRow()':
game.cpp:29:29: error: 'N' was not declared in this scope
   29 |         for (int i = 0; i < N; i++) tree[i] = 0;
      |                             ^
game.cpp: In function 'void ins(int, int, ll, int, int, int)':
game.cpp:69:35: error: 'N' was not declared in this scope
   69 |         tree[node].ins(y, num, 0, N - 1, 1);
      |                                   ^
game.cpp:77:57: error: 'N' was not declared in this scope
   77 |     tree[node].ins(y, gcd(tree[node * 2].getAt(y, y, 0, N - 1, 1), tree[node * 2 + 1].getAt(y, y, 0, N - 1, 1)), 0, N - 1, 1);
      |                                                         ^
game.cpp: In function 'll getAt(int, int, int, int, int, int, int)':
game.cpp:84:44: error: 'N' was not declared in this scope
   84 |         return tree[node].getAt(y1, y2, 0, N - 1, 1);
      |                                            ^
game.cpp: In function 'void update(int, int, ll)':
game.cpp:104:21: error: 'N' was not declared in this scope
  104 |     ins(P, Q, K, 0, N - 1, 1);
      |                     ^
game.cpp: In function 'll calculate(int, int, int, int)':
game.cpp:109:33: error: 'N' was not declared in this scope
  109 |     return getAt(P, U, Q, V, 0, N - 1, 1);
      |                                 ^