Submission #235391

# Submission time Handle Problem Language Result Execution time Memory
235391 2020-05-28T08:05:35 Z crossing0ver Game (IOI13_game) C++17
0 / 100
5 ms 1024 KB
#include<bits/stdc++.h>
#define ll long long
#include "game.h"
using namespace std;

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;
}
ll t[100][4*100001];
ll t1[2000][2001][12];
int fr[2000][12];
int pos,l,r,sd,R,C;
ll val;
void upd (int v,int tl,int tr) {
	if (tl == tr) {
		t[sd][v] = val;
		return;
	}
	int tm = (tl + tr)/2;
	if (pos <= tm) upd(v*2,tl,tm);
	else upd(v*2|1,tm+1,tr);
	t[sd][v] = gcd2(t[sd][v*2],t[sd][v*2|1]);
}

ll get (int v,int tl,int tr) {
	if (l > tr || r < tl) return 0;
	if (l <= tl && r >= tr) {
		return t[sd][v];
	}
	int tm = (tl + tr)/2;
	return gcd2 ( get (v*2,tl,tm), get (v*2|1,tm+1,tr));
}

int i,j,c;
void update(int P, int Q, long long K) {
	sd = P;
	val = K; pos = Q;
	if (C > 2000 || R > 2000)
	upd (1,0,100000);
	else  {
		t1[P][Q][0] = K;
		for (i = Q; i < C; i++) {
			for (j = 1; j < 12 && fr[i][j]; j++) {
				t1[P][i][j] = gcd2(t1[P][i][j-1], t1 [P][fr[i][j] - 1][ j - 1]);  
			}
		}
}
}
ll s;
int sz;
long long calculate(int P, int Q, int U, int V) {
    s = 0;
    l = Q; r = V;
    if (C > 2000 || R > 2000)
    for (sd = P; sd <= U; sd++) 	
    	s = gcd2(s,get (1,0,100000));
    else 
    	for (i = P; i <= U; i++)  {
    	    sz = r - l + 1;
    		c = V;
    		for (j = 0; j < 12 && c != - 1; j++) {
    			if ((1 << j) & sz)
			s = gcd2(s,t1[i][c][j]),
			c = fr[c][j] - 1;
		}
		}
	return s;
}

void init(int R1, int C1) {R = R1; C = C1;
for (int i = 0; i < 2000; i++) fr[i][0] = i,fr[i][1] = (i ? i - 1 : 0);
{
for (int j = 2; j < 12 && fr[i][j - 1]; j++)  fr[i][j] = fr [ (fr[i][ j - 1]) - 1][j-1];
}
}

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 calculate(int, int, int, int)':
game.cpp:63:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
     else 
     ^~~~
game.cpp:73:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  return s;
  ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 1024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 1024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 1024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 416 KB Output is correct
2 Incorrect 5 ms 1024 KB Output isn't correct
3 Halted 0 ms 0 KB -