# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
253091 |
2020-07-26T21:51:44 Z |
test2 |
Game (IOI13_game) |
C++14 |
|
22 ms |
39424 KB |
#include "game.h"
#include<bits/stdc++.h>
const int N = 2e6 + 7 ;
using namespace std ;
int n;
int nodes = 1 ;
long long tree[N * 4] ;
int l[N][2] , r[N][2] ;
int heads[N] ;
int h = 0 ;
int head(int x){
if(heads[x] == -1)
heads[x] = nodes ++ ;
return heads[x] ;
}
void init(int R , int C){
memset(l , -1 , sizeof l) ;
memset(r , -1 , sizeof r) ;
memset(heads , -1 , sizeof heads) ;
}
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;
}
int f(int x, int y){
return gcd2(x , y);
}
int Left(int x , int i = 0){
if(l[x][i] == -1){
l[x][i] = nodes ++ ;
}
return l[x][i] ;
}
int Right(int x , int i = 0 ){
if(r[x][i] == -1){
r[x][i] = nodes ++ ;
}
return r[x][i] ;
}
void update(int node , int L , int R , int idx , int val){
if(L == R){
tree[node] = val ;
return ;
}
int mid = (L + R ) >> 1 ;
if(idx <= mid)
update( Left(node), L ,mid , idx ,val) ;
else
update( Right(node) , mid +1 , R , idx , val) ;
if(l[node][0] == -1)tree[node] = tree[r[node][0]] ;
else if(r[node][0] == -1)tree[node] = tree[l[node][0]] ;
else tree[node] = f(tree[l[node][0]] , tree[r[node][0]] ) ;
return ;
}
int query(int node , int L , int R , int l ,int r){
if(l > r || l > R || r < L || node == -1)
return 0 ;
if(L >= l && R<= r){
return tree[node] ;
}
int mid = (L + R) >> 1;
int s1 = query(Left(node) , L , mid , l , r) ;
int s2 = query(Right(node) , mid+1 ,R , l , r) ;
return f(s1 , s2) ;
}
int segs = 1 ;
void upd(int node , int L , int R , int idX , int idY , int val){
if(L == R){
update( head(node) , 1 , N , idY , val) ;
return ;
}
int mid = (L + R) >> 1;
if(idX<= mid){
upd( Left(node , 1) , L , mid , idX , idY , val) ;
}
else{
upd( Right(node , 1) , mid+1 , R , idX , idY , val) ;
}
update(head(node) , 1 , N , idY , val) ;
}
int query2(int node , int L , int R , int l , int r , int x ,int y){
if(node == -1)
return 0 ;
if(l > r|| l > R || r < L)
return 0 ;
if(L>= l && R<=r ){
return query(head(node) , 1 , N , x ,y) ;
}
int mid = (L + R ) >> 1 ;
int s1 = query2(Left(node ,1) , L , mid , l , r , x , y) ;
int s2 = query2(Right(node , 1) , mid+1 ,R , l , r, x , y) ;
return f(s1 , s2) ;
}
void update(int P, int Q, long long K)
{
P ++ ; Q ++ ;
upd(0 , 1 , N , P , Q , K) ;
}
long long calculate(int P, int Q, int U, int V)
{
P++ ; Q ++ ; U ++ ; V++ ;
return query2(0 , 1 , N , P , U , Q , V) ;
}
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;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
39416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
39424 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
39424 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
39424 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
39424 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |