Submission #96823

#TimeUsernameProblemLanguageResultExecution timeMemory
96823kig9981Game (IOI13_game)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; struct Seg { int ul, ur, dl, dr; long long v; Seg() ul(0), ur(0), dl(0), dr(0), v(0) {} }; vector<Seg> tree(2); void init(int R, int C) { } long long GCD(long long a, long long b) { for(;b;a%=b,swap(a,b)); return a; } void update2(int n, long long v, int p, int s=0, int e=1e9) { int m=(s+e)>>1; if(s==e) { tree[p].v=v; return; } if(n<=m) { if(tree[p].dl==0) tree[p].dl=tree.size(), tree.push_back(Seg()); update2(n,v,tree[p].dl,s,m); } else { if(tree[p].dr==0) tree[p].dr=tree.size(), tree.push_back(Seg()); update2(n,v,tree[p].dr,m+1,e); } tree[p].v=GCD(tree[tree[p].dl].v,tree[tree[p].dr].v); } void update(int x, int y, long long v, int p=1, int s=0, int e=1e9) { int m=(s+e)>>1; update2(y,v,p); if(s==e) return; if(n<=m) { if(tree[p].ul==0) tree[p].ul=tree.size(), tree.push_back(Seg()); update(x,y,v,tree[p].ul,s,m); } else { if(tree[p].ur==0) tree[p].ur=tree.size(), tree.push_back(Seg()); update(x,y,v,tree[p].ur,m+1,e); } } long long get_gcd(int n1, int n2, int p, int s=0, int e=1e9) { int m=(s+e)>>1; if(p==0 || n2<s || e<n1) return 0; if(n1<=s && e<=n2) return tree[p].v; return GCD(get_gcd(n1,n2,tree[p].dl,s,m),get_gcd(n1,n2,tree[p].dr,m+1,e)); } long long calculate(int x1, int y1, int x2, int y2, int p=1, int s=0, int e=1e9) { int m=(s+e)>>1; if(p==0 || x2<s || e<x1) return 0; if(x1<=s && e<=x2) return get_gcd(y1,y2,p); return GCD(calculate(x1,y1,x2,y2,tree[p].ul,s,m),calculate(x1,y1,x2,y2,tree[p].ur,m+1,e)); }

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:10:6: error: expected ';' at end of member declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
      ^
game.cpp:10:11: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
           ^
game.cpp:10:11: error: expected ',' or '...' before numeric constant
game.cpp:10:12: error: ISO C++ forbids declaration of 'ul' with no type [-fpermissive]
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
            ^
game.cpp:10:13: error: 'int Seg::ul(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
             ^
game.cpp:8:6: note: previous declaration 'int Seg::ul'
  int ul, ur, dl, dr;
      ^~
game.cpp:10:18: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                  ^
game.cpp:10:18: error: expected ',' or '...' before numeric constant
game.cpp:10:19: error: ISO C++ forbids declaration of 'ur' with no type [-fpermissive]
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                   ^
game.cpp:10:20: error: 'int Seg::ur(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                    ^
game.cpp:8:10: note: previous declaration 'int Seg::ur'
  int ul, ur, dl, dr;
          ^~
game.cpp:10:25: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                         ^
game.cpp:10:25: error: expected ',' or '...' before numeric constant
game.cpp:10:26: error: ISO C++ forbids declaration of 'dl' with no type [-fpermissive]
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                          ^
game.cpp:10:27: error: 'int Seg::dl(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                           ^
game.cpp:8:14: note: previous declaration 'int Seg::dl'
  int ul, ur, dl, dr;
              ^~
game.cpp:10:32: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                ^
game.cpp:10:32: error: expected ',' or '...' before numeric constant
game.cpp:10:33: error: ISO C++ forbids declaration of 'dr' with no type [-fpermissive]
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                 ^
game.cpp:10:34: error: 'int Seg::dr(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                  ^
game.cpp:8:18: note: previous declaration 'int Seg::dr'
  int ul, ur, dl, dr;
                  ^~
game.cpp:10:38: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                      ^
game.cpp:10:38: error: expected ',' or '...' before numeric constant
game.cpp:10:39: error: ISO C++ forbids declaration of 'v' with no type [-fpermissive]
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                       ^
game.cpp:10:42: error: 'int Seg::v(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                          ^
game.cpp:9:12: note: previous declaration 'long long int Seg::v'
  long long v;
            ^
game.cpp: In member function 'int Seg::v(int)':
game.cpp:10:42: warning: no return statement in function returning non-void [-Wreturn-type]
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                          ^
game.cpp: In function 'void update2(int, long long int, int, int, int)':
game.cpp:30:11: error: invalid use of member function 'int Seg::v(int)' (did you forget the '()' ?)
   tree[p].v=v;
game.cpp:34:14: error: invalid use of member function 'int Seg::dl(int)' (did you forget the '()' ?)
   if(tree[p].dl==0) tree[p].dl=tree.size(), tree.push_back(Seg());
game.cpp:34:29: error: invalid use of member function 'int Seg::dl(int)' (did you forget the '()' ?)
   if(tree[p].dl==0) tree[p].dl=tree.size(), tree.push_back(Seg());
game.cpp:35:29: error: invalid use of non-static member function 'int Seg::dl(int)'
   update2(n,v,tree[p].dl,s,m);
                             ^
game.cpp:10:22: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                      ^~
game.cpp:38:14: error: invalid use of member function 'int Seg::dr(int)' (did you forget the '()' ?)
   if(tree[p].dr==0) tree[p].dr=tree.size(), tree.push_back(Seg());
game.cpp:38:29: error: invalid use of member function 'int Seg::dr(int)' (did you forget the '()' ?)
   if(tree[p].dr==0) tree[p].dr=tree.size(), tree.push_back(Seg());
game.cpp:39:31: error: invalid use of non-static member function 'int Seg::dr(int)'
   update2(n,v,tree[p].dr,m+1,e);
                               ^
game.cpp:10:29: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                             ^~
game.cpp:41:20: error: invalid use of non-static member function 'int Seg::dl(int)'
  tree[p].v=GCD(tree[tree[p].dl].v,tree[tree[p].dr].v);
                    ^
game.cpp:10:22: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                      ^~
game.cpp:41:39: error: invalid use of non-static member function 'int Seg::dr(int)'
  tree[p].v=GCD(tree[tree[p].dl].v,tree[tree[p].dr].v);
                                       ^
game.cpp:10:29: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                             ^~
game.cpp: In function 'void update(int, int, long long int, int, int, int)':
game.cpp:49:5: error: 'n' was not declared in this scope
  if(n<=m) {
     ^
game.cpp:50:14: error: invalid use of member function 'int Seg::ul(int)' (did you forget the '()' ?)
   if(tree[p].ul==0) tree[p].ul=tree.size(), tree.push_back(Seg());
game.cpp:50:29: error: invalid use of member function 'int Seg::ul(int)' (did you forget the '()' ?)
   if(tree[p].ul==0) tree[p].ul=tree.size(), tree.push_back(Seg());
game.cpp:51:30: error: invalid use of non-static member function 'int Seg::ul(int)'
   update(x,y,v,tree[p].ul,s,m);
                              ^
game.cpp:10:8: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
        ^~
game.cpp:54:14: error: invalid use of member function 'int Seg::ur(int)' (did you forget the '()' ?)
   if(tree[p].ur==0) tree[p].ur=tree.size(), tree.push_back(Seg());
game.cpp:54:29: error: invalid use of member function 'int Seg::ur(int)' (did you forget the '()' ?)
   if(tree[p].ur==0) tree[p].ur=tree.size(), tree.push_back(Seg());
game.cpp:55:32: error: invalid use of non-static member function 'int Seg::ur(int)'
   update(x,y,v,tree[p].ur,m+1,e);
                                ^
game.cpp:10:15: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
               ^~
game.cpp: In function 'long long int get_gcd(int, int, int, int, int)':
game.cpp:63:36: error: cannot convert 'Seg::v' from type 'int (Seg::)(int)' to type 'long long int'
  if(n1<=s && e<=n2) return tree[p].v;
                                    ^
game.cpp:64:41: error: invalid use of non-static member function 'int Seg::dl(int)'
  return GCD(get_gcd(n1,n2,tree[p].dl,s,m),get_gcd(n1,n2,tree[p].dr,m+1,e));
                                         ^
game.cpp:10:22: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                      ^~
game.cpp:64:73: error: invalid use of non-static member function 'int Seg::dr(int)'
  return GCD(get_gcd(n1,n2,tree[p].dl,s,m),get_gcd(n1,n2,tree[p].dr,m+1,e));
                                                                         ^
game.cpp:10:29: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                             ^~
game.cpp: In function 'long long int calculate(int, int, int, int, int, int, int)':
game.cpp:72:49: error: invalid use of non-static member function 'int Seg::ul(int)'
  return GCD(calculate(x1,y1,x2,y2,tree[p].ul,s,m),calculate(x1,y1,x2,y2,tree[p].ur,m+1,e));
                                                 ^
game.cpp:10:8: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
        ^~
game.cpp:72:89: error: invalid use of non-static member function 'int Seg::ur(int)'
  return GCD(calculate(x1,y1,x2,y2,tree[p].ul,s,m),calculate(x1,y1,x2,y2,tree[p].ur,m+1,e));
                                                                                         ^
game.cpp:10:15: note: declared here
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
               ^~