Submission #237829

# Submission time Handle Problem Language Result Execution time Memory
237829 2020-06-09T00:27:56 Z mohamedsobhi777 Game (IOI13_game) C++14
10 / 100
6297 ms 4764 KB
#include<bits/stdc++.h>
#include "game.h"
 
#define maxc 1000000000
#define maxr 1000000000
 
using namespace std ; 
 
const int N =10000 + 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] , lc[N * 4] , rc[N * 4 ] ;

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

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 Correct 5 ms 1024 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 5 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 6 ms 1024 KB Output is correct
7 Correct 5 ms 1024 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 5 ms 1024 KB Output is correct
11 Correct 5 ms 1024 KB Output is correct
12 Correct 5 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1024 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Incorrect 884 ms 4592 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1024 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 5 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 5 ms 1024 KB Output is correct
7 Correct 5 ms 1024 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 5 ms 1024 KB Output is correct
11 Correct 5 ms 1024 KB Output is correct
12 Runtime error 6297 ms 4764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1024 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 5 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 5 ms 1024 KB Output is correct
7 Correct 5 ms 1024 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 5 ms 1024 KB Output is correct
11 Correct 5 ms 1024 KB Output is correct
12 Incorrect 925 ms 4728 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1024 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 5 ms 1024 KB Output is correct
4 Correct 5 ms 1024 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 5 ms 1024 KB Output is correct
7 Correct 5 ms 1024 KB Output is correct
8 Correct 5 ms 1024 KB Output is correct
9 Correct 5 ms 1024 KB Output is correct
10 Correct 5 ms 1024 KB Output is correct
11 Correct 5 ms 1024 KB Output is correct
12 Incorrect 910 ms 4576 KB Output isn't correct
13 Halted 0 ms 0 KB -