Submission #43159

#TimeUsernameProblemLanguageResultExecution timeMemory
43159yusufakeGame (IOI13_game)C++98
63 / 100
13123 ms256000 KiB
#include<bits/stdc++.h> #include "game.h" using namespace std; #define tm (tl+tr >> 1) #define mp make_pair #define pb push_back #define st first #define nd second typedef long long ll; typedef pair < int , int > pp; const int mod = 1e9 + 7; const int N = 2e5 + 5; inline ll gcd(ll u, ll v) { ll r; while (v != 0) { r = u % v; u = v; v = r; } return u; } struct node{ ll x; struct node *l, *r, *to_y; node() { x = 0; l = r = to_y = NULL; } ll qry_y(int tl, int tr, int ly, int ry) { if(ly > tr || ry < tl) return 0; if (ly <= tl && tr <= ry) return x; return gcd(l ? l->qry_y(tl,tm,ly,ry) : 0 , r ? r->qry_y(tm+1,tr,ly,ry) : 0); } ll qry_x(int tl, int tr, int lx, int rx, int ly, int ry) { if(lx > tr || rx < tl) return 0; if (lx <= tl && tr <= rx) return to_y ? to_y->qry_y(0,mod,ly,ry) : 0; return gcd(l ? l->qry_x(tl,tm,lx,rx,ly,ry) : 0 , r ? r->qry_x(tm+1,tr,lx,rx,ly,ry) : 0); } void up_y(int tl, int tr, int py, ll val){ if(tl == tr){ x = val; return; } if(py > tm) { if(r == NULL) r = new node; r -> up_y(tm+1,tr,py,val); } else { if(l == NULL) l = new node; l -> up_y(tl,tm,py,val); } x = gcd(l ? l->x : 0 , r ? r->x : 0); } void up_x(int tl, int tr, int px, int py, ll val){ if(tl < tr){ if(px > tm) { if(r == NULL) r = new node; r -> up_x(tm+1,tr,px,py,val); } else { if(l == NULL) l = new node; l -> up_x(tl,tm,px,py,val); } val = gcd(l ? l->to_y->qry_y(0,mod,py,py) : 0 , r ? r->to_y->qry_y(0,mod,py,py) : 0); } if(to_y == NULL) to_y = new node; to_y -> up_y(0,mod,py,val); } } root; void update(int x, int y, ll val){ root.up_x(0,mod,x,y,val); } ll calculate(int lx, int ly, int rx, int ry){ return root.qry_x(0,mod,lx,rx,ly,ry); } void init(int a, int b) {}

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;
      ^
game.cpp: In member function 'll node::qry_y(int, int, int, int)':
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:32:32: note: in expansion of macro 'tm'
     return gcd(l ? l->qry_y(tl,tm,ly,ry) : 0 , r ? r->qry_y(tm+1,tr,ly,ry) : 0);
                                ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:32:61: note: in expansion of macro 'tm'
     return gcd(l ? l->qry_y(tl,tm,ly,ry) : 0 , r ? r->qry_y(tm+1,tr,ly,ry) : 0);
                                                             ^
game.cpp: In member function 'll node::qry_x(int, int, int, int, int, int)':
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:37:32: note: in expansion of macro 'tm'
     return gcd(l ? l->qry_x(tl,tm,lx,rx,ly,ry) : 0 , r ? r->qry_x(tm+1,tr,lx,rx,ly,ry) : 0);
                                ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:37:67: note: in expansion of macro 'tm'
     return gcd(l ? l->qry_x(tl,tm,lx,rx,ly,ry) : 0 , r ? r->qry_x(tm+1,tr,lx,rx,ly,ry) : 0);
                                                                   ^
game.cpp: In member function 'void node::up_y(int, int, int, ll)':
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:42:14: note: in expansion of macro 'tm'
      if(py > tm) { if(r == NULL) r = new node; r -> up_y(tm+1,tr,py,val); }
              ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:42:58: note: in expansion of macro 'tm'
      if(py > tm) { if(r == NULL) r = new node; r -> up_y(tm+1,tr,py,val); }
                                                          ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:43:61: note: in expansion of macro 'tm'
      else        { if(l == NULL) l = new node; l -> up_y(tl,tm,py,val); }
                                                             ^
game.cpp: In member function 'void node::up_x(int, int, int, int, ll)':
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:48:15: note: in expansion of macro 'tm'
       if(px > tm) { if(r == NULL) r = new node; r -> up_x(tm+1,tr,px,py,val); }
               ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:48:59: note: in expansion of macro 'tm'
       if(px > tm) { if(r == NULL) r = new node; r -> up_x(tm+1,tr,px,py,val); }
                                                           ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:49:62: note: in expansion of macro 'tm'
       else        { if(l == NULL) l = new node; l -> up_x(tl,tm,px,py,val); }
                                                              ^
#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...