Submission #349642

# Submission time Handle Problem Language Result Execution time Memory
349642 2021-01-18T05:24:45 Z tengiz05 Game (IOI13_game) C++17
36 / 100
888 ms 117996 KB
#include "game.h"
#ifndef EVAL
#include "grader.c"
#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
}
const int N = 4005;
ll t[N][N], n, m;
ll get(int x1, int y1, int x2, int y2){
	ll res = 0;
	for(x1+=n,x2+=n; x1<=x2; x1>>=1,x2>>=1){
		if(x1&1){
			for(int l=y1+m,r=y2+m; l<=r; l>>=1,r>>=1){
				if(l&1)res = gcd2(res, t[x1][l++]);
				if(!(r&1))res = gcd2(res, t[x1][r--]);
			}
			x1++;
		}if(!(x2&1)){
			for(int l=y1+m,r=y2+m; l<=r; l>>=1,r>>=1){
				if(l&1)res = gcd2(res, t[x2][l++]);
				if(!(r&1))res = gcd2(res, t[x2][r--]);
			}
			x2--;
		}
	}return res;
}

void upd(int x, int y, ll val){
	for(x+=n; x>=1; x>>=1){
		int i = y+m;
		for(; i>0; i>>=1){
			if(x>=n&&i>=m)t[x][i] = val;
			else if(i>=m)t[x][i] = gcd2(t[x<<1][i],t[x<<1|1][i]);
			t[x][i>>1] = gcd2(t[x][i], t[x][i^1]);
		}
	}
}

void init(int R, int C) {
	n = R, m = C;
}

void update(int P, int Q, long long K) {
	upd(P,Q,K);
}

long long calculate(int P, int Q, int U, int V) {
	//~ cout << "the initial array is:\n";
	//~ for(int i=0;i<n;i++){
		//~ for(int j=0;j<m;j++){
			//~ cout << get(i,j,i,j) << ' ';
		//~ }cout << '\n';
	//~ }cout << '\n';
	return get(P, Q, U, V);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 1132 KB Output is correct
10 Correct 1 ms 876 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 382 ms 3052 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 1132 KB Output is correct
10 Correct 1 ms 876 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 593 ms 43628 KB Output is correct
13 Correct 626 ms 35592 KB Output is correct
14 Correct 365 ms 4588 KB Output is correct
15 Correct 801 ms 72556 KB Output is correct
16 Correct 310 ms 117228 KB Output is correct
17 Correct 736 ms 102252 KB Output is correct
18 Correct 888 ms 117612 KB Output is correct
19 Correct 869 ms 117996 KB Output is correct
20 Correct 818 ms 116972 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 1132 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 1132 KB Output is correct
10 Correct 1 ms 876 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Incorrect 384 ms 3052 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 1132 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 1132 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 1132 KB Output is correct
10 Correct 1 ms 876 KB Output is correct
11 Correct 1 ms 512 KB Output is correct
12 Incorrect 380 ms 2924 KB Output isn't correct
13 Halted 0 ms 0 KB -