Submission #590402

#TimeUsernameProblemLanguageResultExecution timeMemory
590402jeroenodbGame (IOI13_game)C++14
Compilation error
0 ms0 KiB
#include "game.h" #include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int mxN = 1e5+1, oo = 1e9; int c; ll ans=0; struct node2 { int pos=-1,len; ll g=0,lazy=0; node2 *l=NULL, *r = NULL; node2(int n) : len(n) {} static ll total(node2* nd) { return nd?gcd(nd->g,nd->lazy):0LL; } void query(int a, int b) { if(b<0 or a>=len) return; if(pos!=-1 and a<=pos and pos<=b) ans = gcd(ans,lazy); if(a<=0 and b>=len-1) { ans = gcd(ans,g); return; } int mid = len/2; if(l) l->query(a,b); if(r) r->query(a-mid,b-mid); } void update(int y, ll v) { if(y==pos or pos==-1) { pos = y; lazy=v; return; } int mid = len/2; if(y<mid) { if(!l) l = new node2(mid); l->update(y,v); } else { if(!r) r = new node2(len-mid); r->update(y-mid,v); } g = gcd(total(l),total(r)); } }; struct node { node *l = NULL, *r = NULL; int len; // make it power of 2? node2 *sub = NULL; node(int n) : len(n) {} node() {} void query(int cc, int dd, int a,int b) { if(dd<0 or cc>=len) return; int mid = len/2; if(cc<=0 and dd>=len-1) { if(sub) sub->query(a,b); return; } if(l) l->query(cc,dd,a,b); if(r) r->query(cc-mid,dd-mid,a,b); } void update(int x, int y, ll v) { int mid = len/2; if(!sub) sub = new node2(c); sub->update(y,v); if(len==1) return; if(x<mid) { if(!l) l = new node(mid); l->update(x,y,v); } else { if(!r) r = new node(len-mid); r->update(x-mid,y,v); } } } root; void init(int R, int C) { c=1e9; root = node(1e9); } 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) { ans=0; root.query(P,U,Q,V); return ans; }

Compilation message (stderr)

game.cpp: In static member function 'static ll node2::total(node2*)':
game.cpp:21:19: error: 'gcd' was not declared in this scope
   21 |         return nd?gcd(nd->g,nd->lazy):0LL;
      |                   ^~~
game.cpp: In member function 'void node2::query(int, int)':
game.cpp:25:49: error: 'gcd' was not declared in this scope
   25 |         if(pos!=-1 and a<=pos and pos<=b) ans = gcd(ans,lazy);
      |                                                 ^~~
game.cpp:27:19: error: 'gcd' was not declared in this scope
   27 |             ans = gcd(ans,g);
      |                   ^~~
game.cpp: In member function 'void node2::update(int, ll)':
game.cpp:48:13: error: 'gcd' was not declared in this scope
   48 |         g = gcd(total(l),total(r));
      |             ^~~