Submission #96812

# Submission time Handle Problem Language Result Execution time Memory
96812 2019-02-12T08:41:48 Z jhnah917 Game (IOI13_game) C++14
0 / 100
2346 ms 257024 KB
#ifndef __GAME_H__
#define __GAME_H__

#ifdef __cplusplus
extern "C" {
#endif


void init(int R, int C);
void update(int P, int Q, long long K);
long long calculate(int P, int Q, int U, int V);
int n, m;

long long f(long long X, long long Y) {
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}

typedef long long T;

T tree[5050][5050];

T ysum(int xnode, int ynode, int ys, int ye, int yl, int yr){
	if(yr < ys || ye < yl) return 0;
	if(yl <= ys && ye <= yr) return tree[xnode][ynode];
	int ym = (ys + ye) >> 1;
	return f(ysum(xnode, ynode*2, ys, ym, yl, yr), ysum(xnode, ynode*2+1, ym+1, ye, yl, yr));
}

T xsum(int xnode, int xs, int xe, int xl, int xr, int yl, int yr){
	if(xr < xs || xe < xl) return 0;
	if(xl <= xs && xe <= xr) return ysum(xnode, 1, 0, m-1, yl, yr);
	int xm = (xs + xe) >> 1;
	return f(xsum(xnode*2, xs, xm, xl, xr, yl, yr), xsum(xnode*2+1, xm+1, xe, xl, xr, yl, yr));
}

void yupdate(int xnode, int xs, int xe, int ynode, int ys, int ye, int x, int y, T val){
	if(ye < y || y < ys) return;
	if(ys^ye){
		int ym = (ys + ye) >> 1;
		yupdate(xnode, xs, xe, ynode*2, ys, ym, x, y, val), yupdate(xnode, xs, xe, ynode*2+1, ym+1, ye, x, y, val);
		tree[xnode][ynode] = f(tree[xnode][ynode*2], tree[xnode][ynode*2+1]);
	}else{
		if(xs^xe) tree[xnode][ynode] = f(tree[xnode*2][ynode], tree[xnode*2+1][ynode]);
		else tree[xnode][ynode] = val;
	}
}

void xupdate(int xnode, int xs, int xe, int x, int y, T val){
	if(xe < x || x < xs) return;
	if(xs^xe){
		int xm = (xs + xe) >> 1;
		xupdate(xnode*2, xs, xm, x, y, val), xupdate(xnode*2+1, xm+1, xe, x, y, val);
	}
	yupdate(xnode, xs, xe, 1, 0, m-1, x, y, val);
}

void init(int R, int C) {
	n = R, m = C;
    for(int i=0; i<8080; i++) for(int j=0; j<8080; j++) tree[i][j] = 0LL;
}

void update(int x, int y, long long val) {
    xupdate(1, 0, n-1, x, y, val);
}

long long calculate(int x1, int y1, int x2, int y2) {
    return xsum(1, 0, n-1, x1, x2, y1, y2);
}

#ifdef __cplusplus
}
#endif

#endif /* __GAME_H__ */

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 'void init(int, int)':
game.cpp:65:68: warning: iteration 5050 invokes undefined behavior [-Waggressive-loop-optimizations]
     for(int i=0; i<8080; i++) for(int j=0; j<8080; j++) tree[i][j] = 0LL;
                                                         ~~~~~~~~~~~^~~~~
game.cpp:65:45: note: within this loop
     for(int i=0; i<8080; i++) for(int j=0; j<8080; j++) tree[i][j] = 0LL;
                                            ~^~~~~
game.cpp:65:68: warning: iteration 5050 invokes undefined behavior [-Waggressive-loop-optimizations]
     for(int i=0; i<8080; i++) for(int j=0; j<8080; j++) tree[i][j] = 0LL;
                                                         ~~~~~~~~~~~^~~~~
game.cpp:65:19: note: within this loop
     for(int i=0; i<8080; i++) for(int j=0; j<8080; j++) tree[i][j] = 0LL;
                  ~^~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2346 ms 257024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 660 ms 257024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 683 ms 257024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 449 ms 257024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 435 ms 257024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -