Submission #43177

#TimeUsernameProblemLanguageResultExecution timeMemory
43177yusufake게임 (IOI13_game)C++98
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "game.h" using namespace std; typedef long long ll; const int mod = 1e9 + 7; const int N = 2e5 + 5; long long gcd(long long X, long long Y) { if(X == 0 || Y == 0) { return X + Y; } long long tmp; while (X != Y && Y != 0) { tmp = X; X = Y; Y = tmp % Y; } return X; } struct node{ ll x; int tl, tr; struct node *l, *r, *to_y; node(int a, int b) : tl(a), tr(b), x(0), l(null), r(null), to_y(null) {} }; ll qry_y(node* p, int ly, int ry) { if(ly > p->tr || ry < p->tl) return 0; if (ly <= p->tl && p->tr <= ry) return p->x; return gcd(p->l ? qry_y(p->l,ly,ry) : 0 , p->r ? qry_y(p->r,ly,ry) : 0); } ll qry_x(node* p, int lx, int rx, int ly, int ry) { if(lx > p->tr || rx < p->tl) return 0; if (lx <= p->tl && p->tr <= rx) return p->to_y ? qry_y(p->to_y,ly,ry) : 0; return gcd(p->l ? qry_x(p->l,lx,rx,ly,ry) : 0 , p->r ? qry_x(p->r,lx,rx,ly,ry) : 0); } void up_y(node* p, int py, ll val){ int tm = p->tl + p->tr >> 1; if(p->tl == p->tr){ p->x = val; return; } if(py > tm) { if(p->r == NULL) p->r = new node(tm+1,p->tr); up_y(p->r,py,val); } else { if(p->l == NULL) p->l = new node(p->tl,tm); up_y(p->l,py,val); } p->x = gcd(p->l ? p->l->x : 0 , p->r ? p->r->x : 0); } void up_x(node* p, int px, int py, ll val){ int tm = p->tl + p->tr >> 1; if(p->tl < p->tr){ if(px > tm) { if(p->r == NULL) p->r = new node(tm+1,p->tr); up_x(p->r,px,py,val); } else { if(p->l == NULL) p->l = new node(p->tl,tm); up_x(p->l,px,py,val); } val = gcd(p->l ? qry_y(p->l->to_y,py,py) : 0 , p->r ? qry_y(p->r->to_y,py,py) : 0); } if(p->to_y == NULL) p->to_y = new node(0,mod); up_y(p->to_y,py,val); } node* root; void update(int x, int y, ll val){ up_x(root,x,y,val); } ll calculate(int lx, int ly, int rx, int ry){ return qry_x(root,lx,rx,ly,ry); } void init(int a, int b) { root = new node(0,mod); }

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 constructor 'node::node(int, int)':
game.cpp:28:48: error: 'null' was not declared in this scope
     node(int a, int b) : tl(a), tr(b), x(0), l(null), r(null), to_y(null) {}
                                                ^
game.cpp:26:13: warning: 'node::tr' will be initialized after [-Wreorder]
     int tl, tr;
             ^
game.cpp:25:8: warning:   'll node::x' [-Wreorder]
     ll x;
        ^
game.cpp:28:5: warning:   when initialized here [-Wreorder]
     node(int a, int b) : tl(a), tr(b), x(0), l(null), r(null), to_y(null) {}
     ^
game.cpp: In function 'void up_y(node*, int, ll)':
game.cpp:43:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
      int tm = p->tl + p->tr >> 1;
                     ^
game.cpp: In function 'void up_x(node*, int, int, ll)':
game.cpp:50:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
      int tm = p->tl + p->tr >> 1;
                     ^