Submission #121975

# Submission time Handle Problem Language Result Execution time Memory
121975 2019-06-27T10:19:16 Z yusufake Game (IOI13_game) C++
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "game.h"
 
using namespace std;
 
#define _   int v, int tl, int tr
#define tm  (tl+tr >> 1)
#define sol L[v],tl,tm
#define sag R[v],tm+1,tr
 
#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   = 22000 * 27 * 27;

#define Y[v] s[v]

int L[N],R[N],id;
ll s[N];


// 0 is empty node 
// s[0] should be ineffective element
// Y[0], L[0], and R[0] should be 0
// 1 is the root of the -x axis segment tree
// Y[v] is the root of the segment tree of the interval that corresponds to node 'v' in -x axis segment tree
 
ll gcd(ll u, ll v) {
    ll r;
    while (v != 0) { r = u % v; u = v; v = r; }
    return u;
} 
 
ll qry_y(_, int ly, int ry) { 
	if(ly > tr || ry < tl || !v) return 0;
	if (ly <= tl && tr <= ry) return s[v];
	return gcd(qry_y(sol,ly,ry) , qry_y(sag,ly,ry));
}
ll qry_x(_, int lx, int rx, int ly, int ry) { 
	if(lx > tr || rx < tl) return 0;
	if (lx <= tl && tr <= rx) return qry_y(Y[v], 0, mod, ly, ry);
	return gcd(qry_x(sol,lx,rx,ly,ry) , qry_x(sag,lx,rx,ly,ry));
}
 
void up_y(_, int posy, int r1, int r2, ll t){  
    if(id == N - 5) while(1);
    if(tl == tr){
		s[v] = t == -1 ? gcd(s[r1] , s[r2]) : t;
		return;
	}
	if(posy > tm) { if(!R[v]) R[v] = ++id; up_y(sag,posy,R[r1],R[r2],t); }
	else          { if(!L[v]) L[v] = ++id; up_y(sol,posy,L[r1],L[r2],t); }
	s[v] = gcd(s[ L[v] ] , s[ R[v] ]);
}
void up_x(_, int posx, int posy, ll t){
    if(id == N - 5) while(1);
	if(tl < tr){
		if(posx > tm) { if(!R[v]) R[v] = ++id; up_x(sag,posx,posy,t); }
		else          { if(!L[v]) L[v] = ++id; up_x(sol,posx,posy,t); }
	}
	if(!Y[v]) Y[v] = ++id;
	up_y(Y[v],0,mod,posy,Y[ L[v] ],Y[ R[v] ],(tl==tr?t:-1));
}
 
 
void update(int posx, int posy, ll t){
	up_x(1,0,mod,posx,posy,t);
}	

ll calculate(int lx, int ly, int rx, int ry){
	return qry_x(1,0,mod,lx,rx,ly,ry);
}	
 
void init(int a, int b) {
    memset(s , 0 , sizeof s);
//    memset(Y , 0 , sizeof Y);
    memset(L , 0 , sizeof L);
    memset(R , 0 , sizeof R);
    id = 1;
}

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:22:10: warning: ISO C++11 requires whitespace after the macro name
 #define Y[v] s[v]
          ^
game.cpp: In function 'll qry_y(int, int, int, int, int)':
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:8:21: note: in expansion of macro 'tm'
 #define sol L[v],tl,tm
                     ^~
game.cpp:43:19: note: in expansion of macro 'sol'
  return gcd(qry_y(sol,ly,ry) , qry_y(sag,ly,ry));
                   ^~~
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:9:18: note: in expansion of macro 'tm'
 #define sag R[v],tm+1,tr
                  ^~
game.cpp:43:38: note: in expansion of macro 'sag'
  return gcd(qry_y(sol,ly,ry) , qry_y(sag,ly,ry));
                                      ^~~
game.cpp: In lambda function:
game.cpp:22:14: error: expected '{' before 's'
 #define Y[v] s[v]
              ^
game.cpp:47:41: note: in expansion of macro 'Y'
  if (lx <= tl && tr <= rx) return qry_y(Y[v], 0, mod, ly, ry);
                                         ^
game.cpp: In function 'll qry_x(int, int, int, int, int, int, int)':
game.cpp:22:14: error: expected ')' before 's'
 #define Y[v] s[v]
              ^
game.cpp:47:41: note: in expansion of macro 'Y'
  if (lx <= tl && tr <= rx) return qry_y(Y[v], 0, mod, ly, ry);
                                         ^
game.cpp:47:61: error: cannot convert 'qry_x(int, int, int, int, int, int, int)::<lambda()>' to 'int' for argument '1' to 'll qry_y(int, int, int, int, int)'
  if (lx <= tl && tr <= rx) return qry_y(Y[v], 0, mod, ly, ry);
                                                             ^
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:8:21: note: in expansion of macro 'tm'
 #define sol L[v],tl,tm
                     ^~
game.cpp:48:19: note: in expansion of macro 'sol'
  return gcd(qry_x(sol,lx,rx,ly,ry) , qry_x(sag,lx,rx,ly,ry));
                   ^~~
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:9:18: note: in expansion of macro 'tm'
 #define sag R[v],tm+1,tr
                  ^~
game.cpp:48:44: note: in expansion of macro 'sag'
  return gcd(qry_x(sol,lx,rx,ly,ry) , qry_x(sag,lx,rx,ly,ry));
                                            ^~~
game.cpp: In function 'void up_y(int, int, int, int, int, int, ll)':
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:57:12: note: in expansion of macro 'tm'
  if(posy > tm) { if(!R[v]) R[v] = ++id; up_y(sag,posy,R[r1],R[r2],t); }
            ^~
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:9:18: note: in expansion of macro 'tm'
 #define sag R[v],tm+1,tr
                  ^~
game.cpp:57:46: note: in expansion of macro 'sag'
  if(posy > tm) { if(!R[v]) R[v] = ++id; up_y(sag,posy,R[r1],R[r2],t); }
                                              ^~~
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:8:21: note: in expansion of macro 'tm'
 #define sol L[v],tl,tm
                     ^~
game.cpp:58:46: note: in expansion of macro 'sol'
  else          { if(!L[v]) L[v] = ++id; up_y(sol,posy,L[r1],L[r2],t); }
                                              ^~~
game.cpp: In function 'void up_x(int, int, int, int, int, ll)':
game.cpp:62:21: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
     if(id == N - 5) while(1);
                     ^~~~~
game.cpp:63:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
  if(tl < tr){
  ^~
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:64:13: note: in expansion of macro 'tm'
   if(posx > tm) { if(!R[v]) R[v] = ++id; up_x(sag,posx,posy,t); }
             ^~
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:9:18: note: in expansion of macro 'tm'
 #define sag R[v],tm+1,tr
                  ^~
game.cpp:64:47: note: in expansion of macro 'sag'
   if(posx > tm) { if(!R[v]) R[v] = ++id; up_x(sag,posx,posy,t); }
                                               ^~~
game.cpp:7:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
              ~~^~
game.cpp:8:21: note: in expansion of macro 'tm'
 #define sol L[v],tl,tm
                     ^~
game.cpp:65:47: note: in expansion of macro 'sol'
   else          { if(!L[v]) L[v] = ++id; up_x(sol,posx,posy,t); }
                                               ^~~
game.cpp: In lambda function:
game.cpp:22:14: error: expected '{' before 's'
 #define Y[v] s[v]
              ^
game.cpp:67:6: note: in expansion of macro 'Y'
  if(!Y[v]) Y[v] = ++id;
      ^
game.cpp: In function 'void up_x(int, int, int, int, int, ll)':
game.cpp:67:5: error: no match for 'operator!' (operand type is 'up_x(int, int, int, int, int, ll)::<lambda()>')
  if(!Y[v]) Y[v] = ++id;
game.cpp:67:5: note: candidate: operator!(bool) <built-in>
game.cpp:67:5: note:   no known conversion for argument 1 from 'up_x(int, int, int, int, int, ll)::<lambda()>' to 'bool'
game.cpp:22:14: error: expected ')' before 's'
 #define Y[v] s[v]
              ^
game.cpp:67:6: note: in expansion of macro 'Y'
  if(!Y[v]) Y[v] = ++id;
      ^
game.cpp: In lambda function:
game.cpp:22:14: error: expected '{' before 's'
 #define Y[v] s[v]
              ^
game.cpp:67:12: note: in expansion of macro 'Y'
  if(!Y[v]) Y[v] = ++id;
            ^
game.cpp: In function 'void up_x(int, int, int, int, int, ll)':
game.cpp:22:14: error: expected ';' before 's'
 #define Y[v] s[v]
              ^
game.cpp:67:12: note: in expansion of macro 'Y'
  if(!Y[v]) Y[v] = ++id;
            ^
game.cpp: In lambda function:
game.cpp:22:14: error: expected '{' before 's'
 #define Y[v] s[v]
              ^
game.cpp:68:7: note: in expansion of macro 'Y'
  up_y(Y[v],0,mod,posy,Y[ L[v] ],Y[ R[v] ],(tl==tr?t:-1));
       ^
game.cpp: In function 'void up_x(int, int, int, int, int, ll)':
game.cpp:22:14: error: expected ')' before 's'
 #define Y[v] s[v]
              ^
game.cpp:68:7: note: in expansion of macro 'Y'
  up_y(Y[v],0,mod,posy,Y[ L[v] ],Y[ R[v] ],(tl==tr?t:-1));
       ^
game.cpp: In lambda function:
game.cpp:22:14: error: expected '{' before 's'
 #define Y[v] s[v]
              ^
game.cpp:68:23: note: in expansion of macro 'Y'
  up_y(Y[v],0,mod,posy,Y[ L[v] ],Y[ R[v] ],(tl==tr?t:-1));
                       ^
game.cpp: In function 'void up_x(int, int, int, int, int, ll)':
game.cpp:22:14: error: expected ')' before 's'
 #define Y[v] s[v]
              ^
game.cpp:68:23: note: in expansion of macro 'Y'
  up_y(Y[v],0,mod,posy,Y[ L[v] ],Y[ R[v] ],(tl==tr?t:-1));
                       ^
game.cpp: In lambda function:
game.cpp:22:14: error: expected '{' before 's'
 #define Y[v] s[v]
              ^
game.cpp:68:33: note: in expansion of macro 'Y'
  up_y(Y[v],0,mod,posy,Y[ L[v] ],Y[ R[v] ],(tl==tr?t:-1));
                                 ^
game.cpp: In function 'void up_x(int, int, int, int, int, ll)':
game.cpp:22:14: error: expected ')' before 's'
 #define Y[v] s[v]
              ^
game.cpp:68:33: note: in expansion of macro 'Y'
  up_y(Y[v],0,mod,posy,Y[ L[v] ],Y[ R[v] ],(tl==tr?t:-1));
                                 ^
game.cpp:68:56: error: cannot convert 'up_x(int, int, int, int, int, ll)::<lambda()>' to 'int' for argument '1' to 'void up_y(int, int, int, int, int, int, ll)'
  up_y(Y[v],0,mod,posy,Y[ L[v] ],Y[ R[v] ],(tl==tr?t:-1));
                                                        ^