Submission #235935

# Submission time Handle Problem Language Result Execution time Memory
235935 2020-05-30T12:08:42 Z crossing0ver Game (IOI13_game) C++17
80 / 100
4797 ms 256004 KB
#include<bits/stdc++.h>
#define ll long long 
#define tree int v,int tl,int tr
#define tm (tl + tr >> 1)
#define lhs L[v],tl,tm
#define rhs R[v], tm+1,tr
#include "game.h"

 
using namespace std;
const int N = 2E7;

int L[N],R[N],A[N],id = 1,posx,posy, lx,ly,rx,ry;
ll ans[N],val;
ll get_y (tree) {
	if (tr < ly || tl > ry || !v) return 0;
	if (tl >= ly && tr <= ry) {
		return ans[v];
	}
	return __gcd ( get_y(lhs),get_y(rhs));	
	
}
ll get_x (tree) {
	if (tr < lx || tl > rx ) return 0;
	if (tl >= lx && tr <= rx) {
		if (!A[v]) return 0;
		return get_y(A[v],0,1e9);
	}
	return __gcd ( get_x (lhs), get_x(rhs));
}
void up_y(tree,int a,int b,bool flag) {
	if (tl == tr)	{
		if (flag) ans[v] = val;
		else ans[v] = __gcd(ans[a],ans[b]);
		return;
	}
	if (posy <= tm) {
		if (!L[v]) L[v] = ++id;
		up_y(lhs,L[a],L[b],flag);
	}
	else {
		if (!R[v]) R[v] = ++id;
		up_y(rhs,R[a],R[b],flag);
	}
	ans[v] = __gcd(ans[ L[v] ],ans[ R[v] ]);
}
void up_x(tree) {
	 if (tl < tr) {
	 	if (posx <= tm) {
	 		if (!L[v]) L[v] = ++id;
	 		up_x(lhs);
		 }
		 else {
		 	if (!R[v]) R[v] = ++id;
	 		up_x(rhs);
		 }
	 }
	 if (!A[v]) A[v] = ++id;
	 up_y(A[ v ],0,1e9,A[ L[v] ], A[ R[v] ],tl == tr); 
}
void update(int x, int y, ll t){
	posx = x;
	posy = y;
	val = t;
	up_x(1,0,1e9);
}
ll calculate(int a, int b, int a2, int b2){
	lx = a; ly = b;
	rx = a2; ry = b2;
	return get_x(1,0,1e9);
}	
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 function 'long long int get_y(int, int, int)':
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:5:21: note: in expansion of macro 'tm'
 #define lhs L[v],tl,tm
                     ^~
game.cpp:20:23: note: in expansion of macro 'lhs'
  return __gcd ( get_y(lhs),get_y(rhs)); 
                       ^~~
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:6:19: note: in expansion of macro 'tm'
 #define rhs R[v], tm+1,tr
                   ^~
game.cpp:20:34: note: in expansion of macro 'rhs'
  return __gcd ( get_y(lhs),get_y(rhs)); 
                                  ^~~
game.cpp: In function 'long long int get_x(int, int, int)':
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:5:21: note: in expansion of macro 'tm'
 #define lhs L[v],tl,tm
                     ^~
game.cpp:29:24: note: in expansion of macro 'lhs'
  return __gcd ( get_x (lhs), get_x(rhs));
                        ^~~
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:6:19: note: in expansion of macro 'tm'
 #define rhs R[v], tm+1,tr
                   ^~
game.cpp:29:36: note: in expansion of macro 'rhs'
  return __gcd ( get_x (lhs), get_x(rhs));
                                    ^~~
game.cpp: In function 'void up_y(int, int, int, int, int, bool)':
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:37:14: note: in expansion of macro 'tm'
  if (posy <= tm) {
              ^~
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:5:21: note: in expansion of macro 'tm'
 #define lhs L[v],tl,tm
                     ^~
game.cpp:39:8: note: in expansion of macro 'lhs'
   up_y(lhs,L[a],L[b],flag);
        ^~~
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:6:19: note: in expansion of macro 'tm'
 #define rhs R[v], tm+1,tr
                   ^~
game.cpp:43:8: note: in expansion of macro 'rhs'
   up_y(rhs,R[a],R[b],flag);
        ^~~
game.cpp: In function 'void up_x(int, int, int)':
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:49:16: note: in expansion of macro 'tm'
    if (posx <= tm) {
                ^~
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:5:21: note: in expansion of macro 'tm'
 #define lhs L[v],tl,tm
                     ^~
game.cpp:51:10: note: in expansion of macro 'lhs'
     up_x(lhs);
          ^~~
game.cpp:4:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl + tr >> 1)
             ~~~^~~
game.cpp:6:19: note: in expansion of macro 'tm'
 #define rhs R[v], tm+1,tr
                   ^~
game.cpp:55:10: note: in expansion of macro 'rhs'
     up_x(rhs);
          ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 640 KB Output is correct
3 Correct 6 ms 640 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 640 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 857 ms 31864 KB Output is correct
5 Correct 647 ms 31608 KB Output is correct
6 Correct 841 ms 29436 KB Output is correct
7 Correct 925 ms 29028 KB Output is correct
8 Correct 631 ms 19704 KB Output is correct
9 Correct 906 ms 29100 KB Output is correct
10 Correct 854 ms 28920 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 768 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 1349 ms 16888 KB Output is correct
13 Correct 1834 ms 10104 KB Output is correct
14 Correct 605 ms 5880 KB Output is correct
15 Correct 2157 ms 13392 KB Output is correct
16 Correct 610 ms 18968 KB Output is correct
17 Correct 1338 ms 15608 KB Output is correct
18 Correct 1998 ms 20200 KB Output is correct
19 Correct 1748 ms 20472 KB Output is correct
20 Correct 1631 ms 19960 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 768 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 6 ms 640 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 841 ms 31736 KB Output is correct
13 Correct 647 ms 31480 KB Output is correct
14 Correct 852 ms 29180 KB Output is correct
15 Correct 892 ms 29080 KB Output is correct
16 Correct 615 ms 19832 KB Output is correct
17 Correct 866 ms 29048 KB Output is correct
18 Correct 836 ms 28792 KB Output is correct
19 Correct 1315 ms 16764 KB Output is correct
20 Correct 1844 ms 10072 KB Output is correct
21 Correct 626 ms 5880 KB Output is correct
22 Correct 2090 ms 13312 KB Output is correct
23 Correct 601 ms 18932 KB Output is correct
24 Correct 1298 ms 15932 KB Output is correct
25 Correct 2040 ms 20444 KB Output is correct
26 Correct 1787 ms 20616 KB Output is correct
27 Correct 1773 ms 19984 KB Output is correct
28 Correct 1018 ms 168344 KB Output is correct
29 Correct 2197 ms 186360 KB Output is correct
30 Correct 4770 ms 127288 KB Output is correct
31 Correct 4476 ms 99012 KB Output is correct
32 Correct 610 ms 10360 KB Output is correct
33 Correct 766 ms 11896 KB Output is correct
34 Correct 1050 ms 179704 KB Output is correct
35 Correct 1596 ms 98168 KB Output is correct
36 Correct 2882 ms 184172 KB Output is correct
37 Correct 2394 ms 184324 KB Output is correct
38 Correct 2386 ms 183480 KB Output is correct
39 Correct 1983 ms 143576 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 640 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 864 ms 32120 KB Output is correct
13 Correct 659 ms 31608 KB Output is correct
14 Correct 854 ms 29432 KB Output is correct
15 Correct 920 ms 29048 KB Output is correct
16 Correct 638 ms 19900 KB Output is correct
17 Correct 958 ms 29432 KB Output is correct
18 Correct 878 ms 28664 KB Output is correct
19 Correct 1403 ms 17220 KB Output is correct
20 Correct 1871 ms 10232 KB Output is correct
21 Correct 636 ms 6008 KB Output is correct
22 Correct 2140 ms 13432 KB Output is correct
23 Correct 603 ms 18836 KB Output is correct
24 Correct 1251 ms 15920 KB Output is correct
25 Correct 1962 ms 20216 KB Output is correct
26 Correct 1786 ms 20344 KB Output is correct
27 Correct 1709 ms 19960 KB Output is correct
28 Correct 976 ms 168312 KB Output is correct
29 Correct 2213 ms 186024 KB Output is correct
30 Correct 4797 ms 127092 KB Output is correct
31 Correct 4580 ms 98776 KB Output is correct
32 Correct 608 ms 10616 KB Output is correct
33 Correct 765 ms 11996 KB Output is correct
34 Correct 1052 ms 179832 KB Output is correct
35 Correct 1712 ms 98088 KB Output is correct
36 Correct 2959 ms 183928 KB Output is correct
37 Correct 2466 ms 184116 KB Output is correct
38 Correct 2392 ms 183648 KB Output is correct
39 Runtime error 968 ms 256004 KB Execution killed with signal 9 (could be triggered by violating memory limits)
40 Halted 0 ms 0 KB -