답안 #152842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152842 2019-09-10T00:39:12 Z jhnah917 게임 (IOI13_game) C++14
0 / 100
2 ms 376 KB
#ifndef __GAME_H__
#define __GAME_H__
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include <math.h>
#include <stdio.h>
 
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 R, C;
 
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 ll;

struct Seg1d{
	ll tree[8080];
	int bias;
	
	void init(int n){
		for(bias=1; bias<=n; bias <<= 1);
	}
	
	void update(int x, ll v){
		x |= bias; tree[x] = v;
		while(x >>= 1){
			tree[x] = f(tree[x << 1], tree[x << 1 | 1]);
		}
	}
	
	ll query(ll l, ll r){
		l |= bias, r |= bias;
		ll ret = 0;
		while(l <= r){
			if(l & 1) ret = f(ret, tree[l++]);
			if(~r & 1) ret = f(ret, tree[r--]);
			l >>= 1, r >>= 1;
		}
		return ret;
	}
};

struct Seg2d{
	Seg1d tree[8080];
	int bias;
	
	void init(int n, int m){
		for(bias=1; bias<=n; bias<<=1);
		for(int i=0; i<bias*2; i++) tree[i].init(m);
	}
	
	void update(int x, int y, ll v){
		x |= bias; tree[x].update(y, v);
		while(x >>= 1){
			ll t1 = tree[x << 1].query(y, y);
			ll t2 = tree[x << 1 | 1 ].query(y, y);
			tree[x].update(y, f(t1, t2));
		}
	}
	
	ll query(ll l, ll r, ll l1, ll r1){
		l |= bias, r |= bias;
		ll ret = 0;
		while(l <= r){
			if(l & 1) tree[l++].query(l1, r1);
			if(~r & 1) tree[r--].query(l1, r1);
			l >>=1 ,r >>= 1;
		}
		return ret;
	}
}tree;
 
void init(int r, int c) {
	R = r, C = c;
}
 
void update(int x, int y, long long val) {
	tree.update(x, y, val);
}
 
long long calculate(int x1, int y1, int x2, int y2) {
    return tree.query(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;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -