Submission #703777

#TimeUsernameProblemLanguageResultExecution timeMemory
703777TheSahibGame (IOI13_game)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "game.h" #define ll long long #define pii pair<int, int> using namespace std; const int MAX = (1 << 30) - 1; const int BRANCH_LOG = 2; const int BRANCH = (1 << BRANCH_LOG); const int TREE_SIZE = 22000 * (30 / BRANCH_LOG); struct SegTree1D{ int nxt = 0; vector<ll> tree; vector<int> L, R; static ll ans = 0; SegTree1D(){ tree.emplace_back(0); L.emplace_back(0); R.emplace_back(0); } int addNode(){ tree.emplace_back(0); L.emplace_back(0); R.emplace_back(0); return ++nxt; } void update(int node, int l, int r, int pos, ll val){ if(l == r){ tree[node] = val; return; } int mid = (l + r) / 2; if(pos <= mid){ if(!L[node]) L[node] = addNode(); update(L[node], l, mid, pos, val); } else{ if(!R[node]) R[node] = addNode(); update(R[node], mid + 1, r, pos, val); } tree[node] = 0; if(L[node]) tree[node] = gcd(tree[node], tree[L[node]]); if(R[node]) tree[node] = gcd(tree[node], tree[R[node]]); } void ask(int node, int l, int r, int ql, int qr){ if(qr < l || r < ql){ return; } if(ql <= l && r <= qr){ ans = gcd(ans, tree[node]); return; } int mid = (l + r) / 2; if(L[node]) ask(L[node], l, mid, ql, qr); if(R[node]) ask(R[node], mid + 1, r, ql, qr); } ll ask(int ql, int qr){ ans = 0; ask(0, 0, MAX, ql, qr); return ans; } }; struct SegTree2D{ static ll ans = 0; int nxt = 0; SegTree1D tree[TREE_SIZE]; int child[TREE_SIZE][BRANCH]; SegTree2D(){ memset(child, 0, sizeof(child)); } void update(int node, int l, int r, int posY, int posX, ll val){ if(l == r){ tree[node].update(0, 0, MAX, posX, val); return; } int inc = (r - l + 1) >> BRANCH_LOG; int uChild = (posY - l) / inc; if(!child[node][uChild]) child[node][uChild] = ++nxt; update(child[node][uChild], l + uChild * inc, l + (uChild + 1) * inc- 1, posY, posX, val); ll a = 0; for (int i = 0; i < BRANCH; i++) { if(child[node][i]) a = gcd(a, tree[child[node][i]].ask(posX, posX)); } tree[node].update(0, 0, MAX, posX, a); } void ask(int node, int l, int r, int qlY, int qrY, int qlX, int qrX){ if(qrY < l || r < qlY){ return; } if(qlY <= l && r <= qrY){ ans = gcd(ans, tree[node].ask(qlX, qrX)); return; } int inc = (r - l + 1) >> BRANCH_LOG; int a = l; for (int i = 0; i < BRANCH; i++) { if(child[node][i]){ ask(child[node][i], a, a + inc - 1, qlY, qrY, qlX, qrX); } a += inc; } } ll ask(int qlY, int qrY, int qlX, int qrX){ ans = 0; ask(0, 0, MAX, qlY, qrY, qlX, qrX); return ans; } }; SegTree2D tree; void init(int R, int C){ } void update(int P, int Q, ll K){ tree.update(0, 0, MAX, P, Q, K); } ll calculate(int P, int Q, int U, int V){ return tree.ask(P, U, Q, V); }

Compilation message (stderr)

game.cpp:19:15: error: ISO C++ forbids in-class initialization of non-const static member 'SegTree1D::ans'
   19 |     static ll ans = 0;
      |               ^~~
game.cpp:72:15: error: ISO C++ forbids in-class initialization of non-const static member 'SegTree2D::ans'
   72 |     static ll ans = 0;
      |               ^~~