답안 #312653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312653 2020-10-14T00:12:21 Z diegogrc 말 (IOI15_horses) C++17
100 / 100
240 ms 58564 KB
#include "horses.h"

#include<bits/stdc++.h>
#define MAX 500005
#define MOD 1000000007
#define mid (l+r)/2
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

struct node
{
    double sum;
    i64 mult;
    double bestsum;
    i64 bestmult;
};

node tree[8*MAX];
i64 xx[MAX];
i64 yy[MAX];
int gN;

void unite( int x , int l , int r )
{
    tree[x].sum =  tree[l].sum + tree[r].sum;
    tree[x].mult = ( tree[l].mult * tree[r].mult ) % MOD;
    
    if( tree[l].bestsum > tree[l].sum + tree[r].bestsum )
    {
        tree[x].bestsum = tree[l].bestsum;
        tree[x].bestmult = tree[l].bestmult;
    }
    else
    {
        tree[x].bestsum = tree[l].sum + tree[r].bestsum;
        tree[x].bestmult = ( tree[l].mult * tree[r].bestmult ) % MOD;
    }
}

void initTree( int x , int l , int r )
{
    if( l == r )
    {
        tree[x].sum = log10( xx[l] );
        tree[x].mult = xx[l] % MOD;
        
        tree[x].bestsum = tree[x].sum + log10( yy[l] );
        tree[x].bestmult = ( tree[x].mult * yy[l] ) % MOD;
        return;
    }
    initTree( 2*x+1 , l , mid );
    initTree( 2*x+2 , mid+1 , r );
    unite( x , 2*x+1 , 2*x+2 );
}



int init(int N, int X[], int Y[]) {
    
    gN = N;
    for( i64 i = 0; i < N; i ++ )
        xx[i] = X[i];
    for( i64 i = 0; i < N; i ++ )
        yy[i] = Y[i];
    
    initTree( 0 , 0 , N - 1 );
    
    return ( int ) tree[0].bestmult;
}

void upd( int x , int l , int r , int q , int v , bool t )
{
    if( l > q or r < q )
        return;
    if( l == r )
    {
        if( ! t )
            xx[l] = v;
        else
            yy[l] = v;
        tree[x].sum = log10( xx[l] );
        tree[x].mult = xx[l] % MOD;
        
        tree[x].bestsum = tree[x].sum + log10( yy[l] );
        tree[x].bestmult = ( tree[x].mult * yy[l] ) % MOD;
        return;
    }
    upd( 2*x+1 , l , mid , q , v , t );
    upd( 2*x+2 , mid+1 , r , q , v , t );
    unite( x , 2*x+1 , 2*x+2 );
}

int updateX(int pos, int val) {	
    upd( 0 , 0 , gN - 1 , pos , val , 0 );
    return ( int ) tree[0].bestmult;
}

int updateY(int pos, int val) {
    upd( 0 , 0 , gN - 1 , pos , val , 1 );
    return ( int ) tree[0].bestmult;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 114 ms 45944 KB Output is correct
2 Correct 240 ms 58564 KB Output is correct
3 Correct 161 ms 49784 KB Output is correct
4 Correct 204 ms 53496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 96 ms 48888 KB Output is correct
34 Correct 96 ms 48888 KB Output is correct
35 Correct 136 ms 55940 KB Output is correct
36 Correct 130 ms 55800 KB Output is correct
37 Correct 66 ms 47164 KB Output is correct
38 Correct 93 ms 47992 KB Output is correct
39 Correct 59 ms 47096 KB Output is correct
40 Correct 95 ms 50936 KB Output is correct
41 Correct 56 ms 47236 KB Output is correct
42 Correct 57 ms 47096 KB Output is correct
43 Correct 89 ms 51448 KB Output is correct
44 Correct 89 ms 51320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 116 ms 49852 KB Output is correct
34 Correct 234 ms 58488 KB Output is correct
35 Correct 160 ms 49656 KB Output is correct
36 Correct 199 ms 53508 KB Output is correct
37 Correct 93 ms 48888 KB Output is correct
38 Correct 94 ms 48888 KB Output is correct
39 Correct 128 ms 55904 KB Output is correct
40 Correct 130 ms 55800 KB Output is correct
41 Correct 63 ms 47096 KB Output is correct
42 Correct 93 ms 47992 KB Output is correct
43 Correct 58 ms 46968 KB Output is correct
44 Correct 97 ms 50976 KB Output is correct
45 Correct 58 ms 47096 KB Output is correct
46 Correct 58 ms 47096 KB Output is correct
47 Correct 90 ms 51320 KB Output is correct
48 Correct 89 ms 51320 KB Output is correct
49 Correct 189 ms 50904 KB Output is correct
50 Correct 190 ms 51064 KB Output is correct
51 Correct 185 ms 57848 KB Output is correct
52 Correct 176 ms 57208 KB Output is correct
53 Correct 159 ms 49272 KB Output is correct
54 Correct 152 ms 49784 KB Output is correct
55 Correct 105 ms 48120 KB Output is correct
56 Correct 147 ms 52728 KB Output is correct
57 Correct 102 ms 48632 KB Output is correct
58 Correct 109 ms 49144 KB Output is correct
59 Correct 92 ms 51320 KB Output is correct