Submission #237813

# Submission time Handle Problem Language Result Execution time Memory
237813 2020-06-08T22:32:52 Z mohamedsobhi777 Game (IOI13_game) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "game.h"


using namespace std ; 

const int N =10000 + 7 ;

int n; 

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;
}

struct dynamic_segmentree{

        int count ; 
        int iden = 0 ; 
        vector<long long> tree ; 
        vector<int> lc , rc ; 

        void init(int _n){
                count = 0 ; 
                tree.resize(4*_n) ; 
                lc = vector<int> (4*_n , -1) ; 
                rc = vector<int> (4*_n , -1) ;
        }

        long long f(int x , int y){
                return gcd2(x , y) ; 
        }

        void update(int node , int L , int R , int ix , int val){
                if(L == R){
                        tree[node] = val ; 
                        return ; 
                }

                int mid = (L+R) >>1 ; 
                if(ix<=mid){
                        if(lc[node] == -1)
                                lc[node] = ++count ; 
                        update(lc[node] , L , mid , ix , val) ; 
                }
                else{
                        if(rc[node] == -1)
                                rc[node] = ++count ; 
                        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]]) ; 
        }

        int 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 ; 
                int s1 = query(lc[node]  , L , mid , l , r) ; 
                int s2 = query(rc[node] , mid+1 , R , l , r) ; 
                return f(s1 , s2) ;
        }

} ; 
vector<dynamic_segmentree> d ; 

void update(int a , int b , int c){
        b++ ; 
        d[a].update(0 , 1 , N , b ,c ) ;
}

long long calculate(int a , int b , int c , int e){
        int ret = 0 ; 
        b++ ; e++ ;
        for(int i = a ; i<=c ;i++){
                ret = gcd2(ret , d[i].query(0 , 1, N , b , e)) ; 
        }
        return ret ; 
}

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;
      ^~~
/tmp/ccgUUX6l.o: In function `main':
grader.c:(.text.startup+0x5d): undefined reference to `init'
grader.c:(.text.startup+0x122): undefined reference to `update'
collect2: error: ld returned 1 exit status