답안 #30060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
30060 2017-07-21T22:55:53 Z Nikefor 게임 (IOI13_game) C++
0 / 100
0 ms 132192 KB
#include "game.h"
long long segment[4096][4096];
int RG, CG;
int x1, y1, x2, y2;
long long val;
long long gcd2(long long X, long long Y) {
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}

void cupdate(int k, int s, int e, int r, int var ) {
	int mid = (s+e)/2;
	if(s<y1 or e>y1) return;
	if(s==e and s==y1) {
		if(var) segment[r][k] = val;
		else segment[r][k] = gcd2( segment[r][k+k],segment[r][k+k+1] );
		return;
	}
	cupdate(k+k,s,mid,r,var);
	cupdate(k+k+1,mid+1,e,r,var);


}

void rupdate(int k, int s, int e) {
	if(s>x1 or e<x1) return;
	if(s==e and s==x1) { cupdate(1, 1, CG, k, 1); return;}
	int mid = (s+e)/2;
	if(mid>x1) rupdate(k+k, s, mid);
	else rupdate(k+k+1, mid+1, e);
	cupdate(1, 1, CG, k, 0);

}
void init(int R, int C) {
	RG = R;
	CG = C;
}
long long cfind(int k, int s, int e, int r) {
	int mid = (s+e)/2;
	if(s>y2 or e<y1) return 0;
	if(s>=y1 and e<=y2) return segment[r][k];
	return gcd2( cfind(k+k,s, mid,r ) ,cfind(k+k+1,mid+1,e,r) );
}
long long rfind(int k, int s, int e) {
	int mid = (s+e)/2;
	if(s>x2 or e<x1) return 0;
	if(s>=x1 and e<=x2) return cfind(1, 1, CG, k );
	return gcd2( rfind(k+k,s,mid),rfind(k+k+1, mid+1, e) );
}
void update(int P, int Q, long long K) {
    x1 = P+1, y1 = Q+1;
    val = K;
    rupdate(1,1,RG);


}

long long calculate(int P, int Q, int U, int V) {   /*P -> U || Q -> v */
	x1 = P+1, y1 = Q+1, x2 = U+1, y2 = V+1;
	return rfind(1, 1, RG);

}

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 Correct 0 ms 132192 KB Output is correct
2 Incorrect 0 ms 132192 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 132192 KB Output is correct
2 Incorrect 0 ms 132192 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 132192 KB Output is correct
2 Incorrect 0 ms 132192 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 132192 KB Output is correct
2 Incorrect 0 ms 132192 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 132192 KB Output is correct
2 Incorrect 0 ms 132192 KB Output isn't correct
3 Halted 0 ms 0 KB -