Submission #799237

#TimeUsernameProblemLanguageResultExecution timeMemory
799237vjudge1Game (IOI13_game)C++98
Compilation error
0 ms0 KiB
#include "game.h" #include<bits/stdc++.h> #define el '\n' #define fi first #define sc second #define pii pair<int, int> #define all(v) v.begin(), v.end() using namespace std; using ll=long long; using ull=unsigned long long; using ld=long double; const int mod=1e9+7; const int N=5e6; int m, n; ll gcd(ll x, ll y) { if(y==0) return x; else return gcd(y, x % y); } ll ss[N]; int L[N], R[N], root[N], lazy[N]; int cur = 1; void down(int v, int l, int r) { int mid = (l + r) >> 1; if (lazy[v] <= mid) { L[v] = ++cur; ss[L[v]] = ss[v]; lazy[L[v]] = lazy[v]; } else { R[v] = ++cur; ss[R[v]] = ss[v]; lazy[R[v]] = lazy[v]; } lazy[v] = 0; } void update1(int v, int l, int r, int pos, ll val) { if (l == r) { ss[v] = val; } else { if (lazy[v]) { if (lazy[v] == pos) { ss[v] = val; } else { down(v, l, r); } } int mid = (l + r) >> 1; if (pos <= mid) { if (!L[v]) { L[v] = ++cur; ss[L[v]] = val; lazy[L[v]] = pos; } else { update1(L[v], l, mid, pos, val); } } else { if (!R[v]) { R[v] = ++cur; ss[R[v]] = val; lazy[R[v]] = pos; } else { update1(R[v], mid + 1, r, pos, val); } } ll gcdL = 0, gcdR = 0; if (L[v]) gcdL = ss[L[v]]; if (R[v]) gcdR = ss[R[v]]; ss[v] = gcd(gcdL, gcdR); } } ll get1(int v, int l, int r, int ql, int qr) { if (ql > r || l > qr) return 0; else if (ql <= l && r <= qr) return ss[v]; else if (lazy[v]) return (ql <= lazy[v] && lazy[v] <= qr) ? ss[v] : 0; else { int mid = (l + r) >> 1; ll gcdL = 0, gcdR = 0; if (L[v]) gcdL = get1(L[v], l, mid, ql, qr); if (R[v]) gcdR = get1(R[v], mid + 1, r, ql, qr); return gcd(gcdL, gcdR); } } void update2(int v, int l, int r, int posR, int posC, ll val) { if (l == r) { if (!root[v]) root[v] = ++cur; update1(root[v], 1, MAXC, posC, val); } else { int mid = (l + r) >> 1; if (posR <= mid) { if (!L[v]) L[v] = ++cur; upate2(L[v], l, mid, posR, posC, val); } else { if (!R[v]) R[v] = ++cur; update2(R[v], mid + 1, r, posR, posC, val); } ll gcdL = 0, gcdR = 0; if (L[v]) gcdL = get1(root[L[v]], 1, MAXC, posC, posC); if (R[v]) gcdR = get1(root[R[v]], 1, MAXC, posC, posC); ll combinedVal = gcd(gcdL, gcdR); if (!root[v]) root[v] = ++cur; update1(root[v], 1, MAXC, posC, combinedVal); } } ll get2(int v, int l, int r, int rowL, int rowR, int colL, int colR) { if (rowL > r || l > rowR) return 0; else if (rowL <= l && r <= rowR) { if (root[v]) return get1(root[v], 1, MAXC, colL, colR); else return 0; } else { int mid = (l + r) >> 1; ll gcdL = 0, gcdR = 0; if (L[v]) gcdL = get2(L[v], l, mid, rowL, rowR, colL, colR); if (R[v]) gcdR = get2(R[v], mid + 1, r, rowL, rowR, colL, colR); return gcd(gcdL, gcdR); } } void init(int R, int C) { m=R; n=C; //ioi kho nhu cai dau khac } void update(int P, int Q, long long K) { update2(1, 1, m, P+1, Q+1, K); } long long calculate(int P, int Q, int U, int V) { return get2(1, 1, m, P+1, Q+1, U+1, V+1); }

Compilation message (stderr)

game.cpp: In function 'void update2(int, int, int, int, int, ll)':
game.cpp:114:29: error: 'MAXC' was not declared in this scope
  114 |         update1(root[v], 1, MAXC, posC, val);
      |                             ^~~~
game.cpp:122:13: error: 'upate2' was not declared in this scope; did you mean 'update2'?
  122 |             upate2(L[v], l, mid, posR, posC, val);
      |             ^~~~~~
      |             update2
game.cpp:130:46: error: 'MAXC' was not declared in this scope
  130 |         if (L[v]) gcdL = get1(root[L[v]], 1, MAXC, posC, posC);
      |                                              ^~~~
game.cpp:131:46: error: 'MAXC' was not declared in this scope
  131 |         if (R[v]) gcdR = get1(root[R[v]], 1, MAXC, posC, posC);
      |                                              ^~~~
game.cpp:134:29: error: 'MAXC' was not declared in this scope
  134 |         update1(root[v], 1, MAXC, posC, combinedVal);
      |                             ^~~~
game.cpp: In function 'll get2(int, int, int, int, int, int, int)':
game.cpp:143:46: error: 'MAXC' was not declared in this scope
  143 |         if (root[v]) return get1(root[v], 1, MAXC, colL, colR);
      |                                              ^~~~