Submission #96822

# Submission time Handle Problem Language Result Execution time Memory
96822 2019-02-12T10:38:37 Z kig9981 Game (IOI13_game) C++17
Compilation error
0 ms 0 KB
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

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:5:6: error: expected ';' at end of member declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
      ^
game.cpp:5:11: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
           ^
game.cpp:5:11: error: expected ',' or '...' before numeric constant
game.cpp:5: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:5:13: error: 'int Seg::ul(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
             ^
game.cpp:3:6: note: previous declaration 'int Seg::ul'
  int ul, ur, dl, dr;
      ^~
game.cpp:5:18: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                  ^
game.cpp:5:18: error: expected ',' or '...' before numeric constant
game.cpp:5: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:5:20: error: 'int Seg::ur(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                    ^
game.cpp:3:10: note: previous declaration 'int Seg::ur'
  int ul, ur, dl, dr;
          ^~
game.cpp:5:25: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                         ^
game.cpp:5:25: error: expected ',' or '...' before numeric constant
game.cpp:5: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:5:27: error: 'int Seg::dl(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                           ^
game.cpp:3:14: note: previous declaration 'int Seg::dl'
  int ul, ur, dl, dr;
              ^~
game.cpp:5:32: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                ^
game.cpp:5:32: error: expected ',' or '...' before numeric constant
game.cpp:5: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:5:34: error: 'int Seg::dr(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                  ^
game.cpp:3:18: note: previous declaration 'int Seg::dr'
  int ul, ur, dl, dr;
                  ^~
game.cpp:5:38: error: expected identifier before numeric constant
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                      ^
game.cpp:5:38: error: expected ',' or '...' before numeric constant
game.cpp:5: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:5:42: error: 'int Seg::v(int)' conflicts with a previous declaration
  Seg() ul(0), ur(0), dl(0), dr(0), v(0) {}
                                          ^
game.cpp:4:12: note: previous declaration 'long long int Seg::v'
  long long v;
            ^
game.cpp: In member function 'int Seg::v(int)':
game.cpp:5: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: At global scope:
game.cpp:8:1: error: 'vector' does not name a type
 vector<Seg> tree(2);
 ^~~~~~
game.cpp: In function 'long long int GCD(long long int, long long int)':
game.cpp:17:14: error: 'swap' was not declared in this scope
  for(;b;a%=b,swap(a,b));
              ^~~~
game.cpp: In function 'void update2(int, long long int, int, int, int)':
game.cpp:25:3: error: 'tree' was not declared in this scope
   tree[p].v=v;
   ^~~~
game.cpp:29:6: error: 'tree' was not declared in this scope
   if(tree[p].dl==0) tree[p].dl=tree.size(), tree.push_back(Seg());
      ^~~~
game.cpp:30:15: error: 'tree' was not declared in this scope
   update2(n,v,tree[p].dl,s,m);
               ^~~~
game.cpp:33:6: error: 'tree' was not declared in this scope
   if(tree[p].dr==0) tree[p].dr=tree.size(), tree.push_back(Seg());
      ^~~~
game.cpp:34:15: error: 'tree' was not declared in this scope
   update2(n,v,tree[p].dr,m+1,e);
               ^~~~
game.cpp:36:2: error: 'tree' was not declared in this scope
  tree[p].v=GCD(tree[tree[p].dl].v,tree[tree[p].dr].v);
  ^~~~
game.cpp: In function 'void update(int, int, long long int, int, int, int)':
game.cpp:44:5: error: 'n' was not declared in this scope
  if(n<=m) {
     ^
game.cpp:45:6: error: 'tree' was not declared in this scope
   if(tree[p].ul==0) tree[p].ul=tree.size(), tree.push_back(Seg());
      ^~~~
game.cpp:46:16: error: 'tree' was not declared in this scope
   update(x,y,v,tree[p].ul,s,m);
                ^~~~
game.cpp:49:6: error: 'tree' was not declared in this scope
   if(tree[p].ur==0) tree[p].ur=tree.size(), tree.push_back(Seg());
      ^~~~
game.cpp:50:16: error: 'tree' was not declared in this scope
   update(x,y,v,tree[p].ur,m+1,e);
                ^~~~
game.cpp: In function 'long long int get_gcd(int, int, int, int, int)':
game.cpp:58:28: error: 'tree' was not declared in this scope
  if(n1<=s && e<=n2) return tree[p].v;
                            ^~~~
game.cpp:59:27: error: 'tree' was not declared in this scope
  return GCD(get_gcd(n1,n2,tree[p].dl,s,m),get_gcd(n1,n2,tree[p].dr,m+1,e));
                           ^~~~
game.cpp: In function 'long long int calculate(int, int, int, int, int, int, int)':
game.cpp:67:35: error: 'tree' was not declared in this scope
  return GCD(calculate(x1,y1,x2,y2,tree[p].ul,s,m),calculate(x1,y1,x2,y2,tree[p].ur,m+1,e));
                                   ^~~~