Submission #729723

# Submission time Handle Problem Language Result Execution time Memory
729723 2023-04-24T12:04:41 Z Jean7 Game (IOI13_game) C++14
37 / 100
765 ms 29204 KB
#include "game.h"
#include <bits/stdc++.h>
#define le (node<<1)
#define ri (node<<1|1)
#define mid ((l+r)>>1)

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

const int N = 1e5+5 ;

long long n , m , a[102][102] ;

struct Segment_Tree {
    long long tree[N<<2] ;
    void build ( int node , int l , int r ) {
        if ( l == r ) {
            tree[node] = 0 ;
        }
        else {
            build ( le , l , mid ) ;
            build ( ri , mid+1 , r ) ;
            tree[node] = gcd2 ( tree[le] , tree[ri] ) ;
        }
    }
    void update ( int node , int l , int r , int i , long long v ) {
        if ( l == r ) {
            tree[node] = v ;
        }
        else {
            if ( i <= mid ) {
                update ( le , l , mid , i , v ) ;
            }
            else {
                update ( ri , mid+1 , r , i , v ) ;
            }
            tree[node] = gcd2 ( tree[le] , tree[ri] ) ;
        }
    }
    long long query ( int node , int l , int r , int x , int y ) {
        if ( l > r || l > y || r < x ) {
            return 0ll ;
        }
        if ( l >= x && r <= y ) {
            return tree[node] ;
        }
        return gcd2 ( query ( le , l , mid , x , y ) , query ( ri , mid+1 , r , x , y ) ) ;
    }
} seg[11] ;

void init(int R, int C) {
    n = R ; m = C ;
    if ( n <= 10 ) {
        for ( int i = 1 ; i <= n ; i++ ) {
            seg[i].build ( 1 , 1 , m ) ;
        }
        return ;
    }
}

void update(int P, int Q, long long K) {
    P++ ; Q++ ;
    if ( n <= 10 ) {
        seg[P].update ( 1 , 1 , m , Q , K ) ;
        return ;
    }
    a[P][Q] = K ;
}

long long calculate(int P, int Q, int U, int V) {
    long long ret = 0 ;
    P++ ; Q++ ; U++ ; V++ ;
    if ( n <= 10 ) {
        for ( int i = P ; i <= U ; i++ ) {
            ret = gcd2 ( ret , seg[i].query ( 1 , 1 , m , Q , V ) ) ;
        }
        return ret ;
    }
    for ( int i = P ; i <= U ; i++ ) {
        for ( int j = Q ; j <= V ; j++ ) {
            ret = gcd2 ( ret , a[i][j] ) ;
        }
    }
    return ret ;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 765 ms 24884 KB Output is correct
5 Correct 461 ms 25224 KB Output is correct
6 Correct 611 ms 22136 KB Output is correct
7 Correct 681 ms 21700 KB Output is correct
8 Correct 564 ms 22688 KB Output is correct
9 Correct 621 ms 21896 KB Output is correct
10 Correct 610 ms 21536 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 308 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Runtime error 1 ms 468 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 699 ms 28972 KB Output is correct
13 Correct 446 ms 28384 KB Output is correct
14 Correct 634 ms 25196 KB Output is correct
15 Correct 638 ms 25184 KB Output is correct
16 Correct 538 ms 26188 KB Output is correct
17 Correct 640 ms 25544 KB Output is correct
18 Correct 568 ms 25180 KB Output is correct
19 Runtime error 2 ms 468 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 713 ms 28464 KB Output is correct
13 Correct 469 ms 29204 KB Output is correct
14 Correct 648 ms 26804 KB Output is correct
15 Correct 664 ms 26212 KB Output is correct
16 Correct 548 ms 26060 KB Output is correct
17 Correct 642 ms 25296 KB Output is correct
18 Correct 547 ms 24920 KB Output is correct
19 Runtime error 2 ms 456 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -