Submission #258791

#TimeUsernameProblemLanguageResultExecution timeMemory
258791davi_bartGame (IOI13_game)C++14
80 / 100
3607 ms256004 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; #define ll long long mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll dim=1<<30; class segment{ public: struct node{ ll val; int left,right; node(){ val=0; left=right=-1; } }; vector<node> s=vector<node>(1); node def; ll upd(int pos,int l,int r,int p,ll v){ if(l>p || r<p)return s[pos].val; if(l==r)return s[pos].val=v; ll x=0,y=0; if(p<=(l+r)/2){ if(s[pos].left==-1){ s[pos].left=s.size(); s.push_back(def); } if(s[pos].right!=-1)y=upd(s[pos].right,(l+r)/2+1,r,p,v); x=upd(s[pos].left,l,(l+r)/2,p,v); }else{ if(s[pos].right==-1){ s[pos].right=s.size(); s.push_back(def); } if(s[pos].left!=-1)x=upd(s[pos].left,l,(l+r)/2,p,v); y=upd(s[pos].right,(l+r)/2+1,r,p,v); } return s[pos].val=__gcd(x,y); } ll query(ll pos,ll l,ll r,ll a,ll b){ if(b<l || r<a)return 0; if(a<=l && r<=b){ return s[pos].val; } ll sx=0,dx=0; if(s[pos].left!=-1)sx=query(s[pos].left,l,(l+r)/2,a,b); if(s[pos].right!=-1)dx=query(s[pos].right,(l+r)/2+1,r,a,b); return __gcd(sx,dx); } }; class segofseg{ public: struct node{ ll left,right; segment k; node(){ left=right=-1; } }; vector<node> s=vector<node>(1); node def; void upd(ll pos,ll l,ll r,ll p,ll q,ll v){ if(l>p || r<p)return ; if(l==r){ s[pos].k.upd(0,0,dim-1,q,v); return; } ll x=0,y=0; if(p<=(l+r)/2){ if(s[pos].left==-1){ s[pos].left=s.size(); s.push_back(def); } upd(s[pos].left,l,(l+r)/2,p,q,v); }else{ if(s[pos].right==-1){ s[pos].right=s.size(); s.push_back(def); } upd(s[pos].right,(l+r)/2+1,r,p,q,v); } if(s[pos].left!=-1)x=s[s[pos].left].k.query(0,0,dim-1,q,q); if(s[pos].right!=-1)y=s[s[pos].right].k.query(0,0,dim-1,q,q); s[pos].k.upd(0,0,dim-1,q,__gcd(x,y)); } ll query(ll pos,ll l,ll r,ll a,ll b,ll x,ll y){ if(b<l || r<a)return 0; if(a<=l && r<=b){ return s[pos].k.query(0,0,dim-1,x,y); } ll sx=0,dx=0; if(s[pos].left!=-1)sx=query(s[pos].left,l,(l+r)/2,a,b,x,y); if(s[pos].right!=-1)dx=query(s[pos].right,(l+r)/2+1,r,a,b,x,y); return __gcd(sx,dx); } }tot; void init(int R, int C) { } void update(int P, int Q, long long K){ tot.upd(0,0,dim-1,P,Q,K); } long long calculate(int P, int Q, int U, int V) { return tot.query(0,0,dim-1,P,U,Q,V); }

Compilation message (stderr)

grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...