답안 #43155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43155 2018-03-09T15:55:37 Z yusufake 게임 (IOI13_game) C++
0 / 100
2 ms 660 KB
#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; }
    node* nw(){
	   node *p = (node *)malloc(sizeof(node));	
	   return p;
    }

    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 = nw(); r -> up_y(tl,tm,py,val); }
	    else        { if(l == NULL) l = nw(); l -> up_y(tm+1,tr,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 = nw(); r -> up_x(tl,tm,px,py,val); }
		    else        { if(l == NULL) l = nw(); l -> up_x(tm+1,tr,px,py,val); }
	    }
	    if(tl < tr) 
            val = gcd(l ? l->qry_y(0,mod,py,py) : 0 , r ? r->qry_y(0,mod,py,py) : 0);
	    if(to_y == NULL) to_y = nw(); 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

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:36: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:36: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:41:32: note: in expansion of macro 'tm'
     return gcd(l ? l->qry_x(tl,tm,lx,rx,ly,ry) : 0 , 
                                ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:42:32: note: in expansion of macro 'tm'
                   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:49:14: note: in expansion of macro 'tm'
      if(py > tm) { if(r == NULL) r = nw(); r -> up_y(tl,tm,py,val); }
              ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:49:57: note: in expansion of macro 'tm'
      if(py > tm) { if(r == NULL) r = nw(); r -> up_y(tl,tm,py,val); }
                                                         ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:50:54: note: in expansion of macro 'tm'
      else        { if(l == NULL) l = nw(); l -> up_y(tm+1,tr,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:55:15: note: in expansion of macro 'tm'
       if(px > tm) { if(r == NULL) r = nw(); r -> up_x(tl,tm,px,py,val); }
               ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:55:58: note: in expansion of macro 'tm'
       if(px > tm) { if(r == NULL) r = nw(); r -> up_x(tl,tm,px,py,val); }
                                                          ^
game.cpp:6:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm  (tl+tr >> 1)
                ^
game.cpp:56:55: note: in expansion of macro 'tm'
       else        { if(l == NULL) l = nw(); l -> up_x(tm+1,tr,px,py,val); }
                                                       ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 660 KB Output isn't correct
2 Halted 0 ms 0 KB -