Submission #799158

#TimeUsernameProblemLanguageResultExecution timeMemory
799158alittlemiddleGame (IOI13_game)C++14
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=6e6+11; ll m, n; ll gcd(ll x, ll y) { return __gcd(x, y); } ll ss[N]; int L[N], R[N], root[N], lazy[N]; int cur = 1; void down(int id, int l, int r) { int mid = (l + r) >> 1; if (lazy[id] <= mid) { L[id] = ++cur; ss[L[id]] = ss[id]; lazy[L[id]] = lazy[id]; } else { R[id] = ++cur; ss[R[id]] = ss[id]; lazy[R[id]] = lazy[id]; } lazy[id] = 0; } void update1(int id, int l, int r, int pos, ll val) { if (l==r) { ss[id] = val; return; } if(lazy[id]) { if(lazy[id]==pos) ss[id] = val; else down(id, l, r); } int mid = (l+r)>>1; if(pos<=mid) { if (!L[id]) { L[id] = ++cur; ss[L[id]] = val; lazy[L[id]] = pos; } else update1(L[id], l, mid, pos, val); } else { if(!R[id]) { R[id] = ++cur; ss[R[id]] = val; lazy[R[id]] = pos; } else update1(R[id], mid + 1, r, pos, val); } ll s1 = 0, s2 = 0; if(L[id]) s1=ss[L[id]]; if(R[id]) s2=ss[R[id]]; ss[id] = gcd(s1, s2); } ll get1(int id, int l, int r, int a, int b) { if(a>r || l>b) return 0; if(a<=l && r<=b) return ss[id]; if(lazy[id]) { if(a<=lazy[id] && lazy[id]<=b) return ss[id]; else return 0; } int mid=(l+r)>>1; ll s1=0, s2=0; if(L[id]) s1 = get1(L[id], l, mid, a, b); if(R[id]) s2 = get1(R[id], mid+1, r, a, b); return gcd(s1, s2); } void update2(int id, int l, int r, int a, int b, ll val) { if(l==r) { if (!root[id]) root[id] = ++cur; update1(root[id], 1, 2e9, b, val); } else { int mid = (l + r) >> 1; if (a <= mid) { if (!L[id]) L[id] = ++cur; update2(L[id], l, mid, a, b, val); } else { if (!R[id]) R[id] = ++cur; update2(R[id], mid + 1, r, a, b, val); } ll s1 = 0, s2 = 0; if(L[id]) s1 = get1(root[L[id]], 1, 2e9, b, b); if(R[id]) s2 = get1(root[R[id]], 1, 2e9, b, b); ll s3 = gcd(s1, s2); if(!root[id]) root[id] = ++cur; update1(root[id], 1, 2e9, b, s3); } } ll get2(int id, int l, int r, int a, int b, int u, int v) { if(a>r || l>b) return 0; if(a<=l && r<=b) { if (root[id]) return get1(root[id], 1, 2e9, u, v); else return 0; } else { int mid=(l+r)>>1; ll s1 = 0, s2 = 0; if (L[id]) s1 = get2(L[id], l, mid, a, b, u, v); if (R[id]) s2 = get2(R[id], mid + 1, r, a, b, u, v); return gcd(s1, s2); } } void init(int R, int C) { root = new node2(0, 2e9); } void update(int P, int Q, long long K) { root->update(P, Q, K); } long long calculate(int P, int Q, int U, int V) { return root->get(P, Q, U, V); }

Compilation message (stderr)

game.cpp: In function 'void init(int, int)':
game.cpp:139:16: error: expected type-specifier before 'node2'
  139 |     root = new node2(0, 2e9);
      |                ^~~~~
game.cpp: In function 'void update(int, int, long long int)':
game.cpp:144:11: error: request for member 'update' in '*(int*)(& root)', which is of non-class type 'int'
  144 |     root->update(P, Q, K);
      |           ^~~~~~
game.cpp: In function 'long long int calculate(int, int, int, int)':
game.cpp:149:18: error: request for member 'get' in '*(int*)(& root)', which is of non-class type 'int'
  149 |     return root->get(P, Q, U, V);
      |                  ^~~