Submission #866897

# Submission time Handle Problem Language Result Execution time Memory
866897 2023-10-27T09:47:33 Z JakobZorz Horses (IOI15_horses) C++14
100 / 100
1197 ms 75060 KB
#include<iostream>
#include<math.h>
#include"horses.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD=(int)1e9+7;
const int TREE_SIZE=1<<19;

int n;
ld xlog[500000];
int y[500000];
ld ylog[500000];

ll powm(ll base,ll exp){
    base%=MOD;
    exp%=MOD-1;
    ll res=1;
    for(int i=0;i<32;i++){
        if(exp&(1<<i))
            res=res*base%MOD;
        base=base*base%MOD;
    }
    return res;
}

ld tree1[2*TREE_SIZE];
ld lazy1[2*TREE_SIZE];

// push lazy
void update1(int node){
    if(lazy1[node]!=0){
        tree1[node]+=lazy1[node];
        if(node<TREE_SIZE){
            lazy1[2*node]+=lazy1[node];
            lazy1[2*node+1]+=lazy1[node];
        }
        lazy1[node]=0;
    }
}

void add1(int node,int l,int r,int rl,int rr,ld c){
    if(l<=rl&&rr<=r){
        lazy1[node]+=c;
        update1(node);
        return;
    }
    
    update1(node);
    
    if(rr<=l||r<=rl)
        return;
    
    int mid=(rl+rr)/2;
    add1(2*node,l,r,rl,mid,c);
    add1(2*node+1,l,r,mid,rr,c);
    tree1[node]=max(tree1[2*node],tree1[2*node+1]);
}

int get1(int node,int rl,int rr){
    if(rl==rr-1)
        return rl;
    int mid=(rl+rr)/2;
    if(tree1[2*node]>=tree1[2*node+1])
        return get1(2*node,rl,mid);
    else
        return get1(2*node+1,mid,rr);
}

int get_maxi(){
    return get1(1,0,TREE_SIZE);
}


ll tree2[2*TREE_SIZE];

void set2(int node,int pos,int rl,int rr,int val){
    if(rl==rr-1){
        tree2[node]=val;
        return;
    }
    
    int mid=(rl+rr)/2;
    if(pos<mid)
        set2(2*node,pos,rl,mid,val);
    else
        set2(2*node+1,pos,mid,rr,val);
    tree2[node]=tree2[2*node]*tree2[2*node+1]%MOD;
}

ll get2(int node,int pos,int rl,int rr){
    if(rr<=pos)
        return tree2[node];
    
    if(pos<rl)
        return 1;
    
    if(rl==rr-1)
        return tree2[node];
    
    int mid=(rl+rr)/2;
    return get2(2*node,pos,rl,mid)*get2(2*node+1,pos,mid,rr)%MOD;
}

int get_prod(int maxi){
    /*ll res=1;
    for(int i=0;i<=maxi;i++){
        res*=x[i];
        res%=MOD;
    }
    return int(res*y[maxi]%MOD);*/
    return int(get2(1,maxi,0,TREE_SIZE)*y[maxi]%MOD);
}

void setx(int pos,int val){
    ld new_val=log(val);
    add1(1,pos,n,0,TREE_SIZE,new_val-xlog[pos]);
    xlog[pos]=new_val;
    set2(1,pos,0,TREE_SIZE,val);
}


void sety(int pos,int val){
    y[pos]=val;
    ld new_val=log(val);
    add1(1,pos,pos+1,0,TREE_SIZE,new_val-ylog[pos]);
    ylog[pos]=new_val;
}

// -------------------------------

int init(int N,int X[],int Y[]){
    for(int i=0;i<2*TREE_SIZE;i++)
        tree2[i]=1;
    
    n=N;
    for(int i=0;i<n;i++){
        setx(i,X[i]);
        sety(i,Y[i]);
    }
    return get_prod(get_maxi());
}

int updateX(int pos,int val){
    setx(pos,val);
    return get_prod(get_maxi());
}

int updateY(int pos,int val){
    sety(pos,val);
    return get_prod(get_maxi());
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 16988 KB Output is correct
2 Correct 3 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 2 ms 12892 KB Output is correct
5 Correct 2 ms 14940 KB Output is correct
6 Correct 2 ms 14936 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 2 ms 14936 KB Output is correct
10 Correct 3 ms 14940 KB Output is correct
11 Correct 2 ms 14940 KB Output is correct
12 Correct 2 ms 16988 KB Output is correct
13 Correct 2 ms 12912 KB Output is correct
14 Correct 3 ms 16988 KB Output is correct
15 Correct 3 ms 14940 KB Output is correct
16 Correct 3 ms 14936 KB Output is correct
17 Correct 2 ms 14940 KB Output is correct
18 Correct 3 ms 14936 KB Output is correct
19 Correct 2 ms 14940 KB Output is correct
20 Correct 2 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 16988 KB Output is correct
2 Correct 3 ms 12888 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 2 ms 13144 KB Output is correct
5 Correct 2 ms 14936 KB Output is correct
6 Correct 2 ms 14940 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 2 ms 14940 KB Output is correct
10 Correct 2 ms 14940 KB Output is correct
11 Correct 2 ms 14940 KB Output is correct
12 Correct 2 ms 16988 KB Output is correct
13 Correct 2 ms 12892 KB Output is correct
14 Correct 2 ms 16988 KB Output is correct
15 Correct 2 ms 14940 KB Output is correct
16 Correct 3 ms 14940 KB Output is correct
17 Correct 2 ms 14936 KB Output is correct
18 Correct 3 ms 14936 KB Output is correct
19 Correct 3 ms 14940 KB Output is correct
20 Correct 2 ms 12892 KB Output is correct
21 Correct 2 ms 13044 KB Output is correct
22 Correct 2 ms 12892 KB Output is correct
23 Correct 4 ms 11100 KB Output is correct
24 Correct 5 ms 14940 KB Output is correct
25 Correct 5 ms 11096 KB Output is correct
26 Correct 4 ms 11096 KB Output is correct
27 Correct 5 ms 14940 KB Output is correct
28 Correct 5 ms 16988 KB Output is correct
29 Correct 5 ms 14940 KB Output is correct
30 Correct 5 ms 11100 KB Output is correct
31 Correct 5 ms 14940 KB Output is correct
32 Correct 6 ms 14940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1002 ms 64076 KB Output is correct
2 Correct 1154 ms 75032 KB Output is correct
3 Correct 1144 ms 66252 KB Output is correct
4 Correct 1197 ms 70076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 16988 KB Output is correct
2 Correct 2 ms 13144 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 2 ms 12952 KB Output is correct
5 Correct 2 ms 14940 KB Output is correct
6 Correct 2 ms 14940 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 2 ms 14940 KB Output is correct
10 Correct 2 ms 14940 KB Output is correct
11 Correct 2 ms 14940 KB Output is correct
12 Correct 2 ms 16988 KB Output is correct
13 Correct 2 ms 12892 KB Output is correct
14 Correct 2 ms 16988 KB Output is correct
15 Correct 2 ms 14936 KB Output is correct
16 Correct 2 ms 14940 KB Output is correct
17 Correct 3 ms 14940 KB Output is correct
18 Correct 2 ms 14940 KB Output is correct
19 Correct 2 ms 14940 KB Output is correct
20 Correct 2 ms 12892 KB Output is correct
21 Correct 2 ms 12892 KB Output is correct
22 Correct 2 ms 12892 KB Output is correct
23 Correct 5 ms 11100 KB Output is correct
24 Correct 5 ms 14936 KB Output is correct
25 Correct 5 ms 10844 KB Output is correct
26 Correct 4 ms 11100 KB Output is correct
27 Correct 5 ms 14940 KB Output is correct
28 Correct 5 ms 16988 KB Output is correct
29 Correct 5 ms 14940 KB Output is correct
30 Correct 4 ms 10844 KB Output is correct
31 Correct 5 ms 15076 KB Output is correct
32 Correct 5 ms 14936 KB Output is correct
33 Correct 819 ms 61568 KB Output is correct
34 Correct 825 ms 65952 KB Output is correct
35 Correct 945 ms 72508 KB Output is correct
36 Correct 924 ms 72480 KB Output is correct
37 Correct 828 ms 63944 KB Output is correct
38 Correct 939 ms 64944 KB Output is correct
39 Correct 796 ms 56148 KB Output is correct
40 Correct 953 ms 67460 KB Output is correct
41 Correct 831 ms 56252 KB Output is correct
42 Correct 803 ms 56336 KB Output is correct
43 Correct 898 ms 67924 KB Output is correct
44 Correct 893 ms 67816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 16984 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 2 ms 12904 KB Output is correct
5 Correct 2 ms 14940 KB Output is correct
6 Correct 2 ms 14968 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 2 ms 14940 KB Output is correct
10 Correct 2 ms 14940 KB Output is correct
11 Correct 2 ms 14940 KB Output is correct
12 Correct 2 ms 16988 KB Output is correct
13 Correct 2 ms 12892 KB Output is correct
14 Correct 3 ms 16988 KB Output is correct
15 Correct 2 ms 14940 KB Output is correct
16 Correct 2 ms 14936 KB Output is correct
17 Correct 2 ms 14940 KB Output is correct
18 Correct 3 ms 14936 KB Output is correct
19 Correct 2 ms 14940 KB Output is correct
20 Correct 2 ms 12892 KB Output is correct
21 Correct 2 ms 12892 KB Output is correct
22 Correct 2 ms 12892 KB Output is correct
23 Correct 5 ms 11100 KB Output is correct
24 Correct 5 ms 14940 KB Output is correct
25 Correct 4 ms 11100 KB Output is correct
26 Correct 4 ms 10844 KB Output is correct
27 Correct 5 ms 14956 KB Output is correct
28 Correct 5 ms 16988 KB Output is correct
29 Correct 5 ms 14940 KB Output is correct
30 Correct 5 ms 11096 KB Output is correct
31 Correct 4 ms 14940 KB Output is correct
32 Correct 5 ms 14940 KB Output is correct
33 Correct 977 ms 64280 KB Output is correct
34 Correct 1165 ms 75060 KB Output is correct
35 Correct 1104 ms 66188 KB Output is correct
36 Correct 1170 ms 70288 KB Output is correct
37 Correct 847 ms 65372 KB Output is correct
38 Correct 860 ms 65964 KB Output is correct
39 Correct 945 ms 72508 KB Output is correct
40 Correct 916 ms 72380 KB Output is correct
41 Correct 808 ms 63744 KB Output is correct
42 Correct 939 ms 64924 KB Output is correct
43 Correct 834 ms 56148 KB Output is correct
44 Correct 923 ms 67408 KB Output is correct
45 Correct 805 ms 56396 KB Output is correct
46 Correct 780 ms 56188 KB Output is correct
47 Correct 951 ms 68132 KB Output is correct
48 Correct 946 ms 67788 KB Output is correct
49 Correct 1034 ms 67368 KB Output is correct
50 Correct 1020 ms 67792 KB Output is correct
51 Correct 1008 ms 74184 KB Output is correct
52 Correct 1033 ms 74060 KB Output is correct
53 Correct 1035 ms 66332 KB Output is correct
54 Correct 1134 ms 66700 KB Output is correct
55 Correct 911 ms 57432 KB Output is correct
56 Correct 1067 ms 69128 KB Output is correct
57 Correct 862 ms 58196 KB Output is correct
58 Correct 896 ms 58296 KB Output is correct
59 Correct 915 ms 67884 KB Output is correct