This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "game.h"
#define maxc 1000000000
#define maxr 1000000000
using namespace std ;
const int N =100000 + 7 ;
int n , count_nodes ;
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;
}
long long tree[N * 4 * 10 ] , lc[N * 4 * 10 ] , rc[N * 4 * 10 ] ;
struct dynamic_segmentree{
long long iden = 0 ;
long long f(long long x , long long y){
return gcd2(x , y) ;
}
void update(int node , int L , int R , int ix , long long val){
// cout<< node <<" " << L <<" " << R <<" " << ix <<" " << val <<"....\n";
if(L == R){
tree[node] = val ;
return ;
}
int mid = (L+R) >>1 ;
if(ix<=mid){
if(lc[node] == -1)
lc[node] = ++count_nodes ;
update(lc[node] , L , mid , ix , val) ;
}
else{
if(rc[node] == -1)
rc[node] = ++count_nodes ;
update(rc[node] , mid+1 , R , ix , val) ;
}
if(lc[node] == -1)
tree[node] = tree[rc[node]] ;
else if(rc[node] == -1)
tree[node] = tree[lc[node]] ;
else tree[node] = f(tree[lc[node]] , tree[rc[node]]) ;
}
long long query(int node , int L , int R , int l , int r){
if(l > R || r < L || node == -1)
return iden ;
if(L>=l && R<=r)
return tree[node] ;
int mid = (L+R) >>1 ;
long long s1 = query(lc[node] , L , mid , l , r) ;
long long s2 = query(rc[node] , mid+1 , R , l , r) ;
return f(s1 , s2) ;
}
} ;
vector<dynamic_segmentree> d ;
int root[N] ;
void update(int a , int b , long long c){
b++ ;
if(root[a] == -1){
root[a] = ++count_nodes ;
}
d[a].update(root[a] , 1 , maxc , b ,c ) ;
}
long long calculate(int a , int b , int c , int e){
long long ret = 0 ;
b++ ; e++ ;
for(int i = a ; i<=c ;i++){
ret = gcd2(ret , d[i].query(root[i] , 1, maxc , b , e)) ;
}
return ret ;
}
void init(int R, int C) {
memset(root , -1 , sizeof root) ;
memset(lc ,-1 , sizeof lc) ;
memset(rc , -1 , sizeof rc) ;
d.resize(R+10) ;
}
Compilation message (stderr)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |