답안 #866818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866818 2023-10-27T08:05:53 Z JakobZorz 말 (IOI15_horses) C++14
0 / 100
1500 ms 57412 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;
int x[500000];
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(){
    /*ld curr=1;
    ld mx=0;
    int maxi=0;
    for(int i=0;i<n;i++){
        curr+=xlog[i];
        if(mx<curr+ylog[i]){
            mx=curr+ylog[i];
            maxi=i;
        }
    }
    
    return maxi;*/
    
    return get1(1,0,TREE_SIZE);
}

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

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


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

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

int init(int N,int X[],int Y[]){
    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());
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6592 KB Output is correct
9 Correct 1 ms 8540 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 1 ms 8684 KB Output is correct
12 Runtime error 13 ms 21360 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 2 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 8540 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Runtime error 12 ms 21340 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1537 ms 57412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 10584 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 8540 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 1 ms 8724 KB Output is correct
12 Runtime error 15 ms 21340 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 10588 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 2 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 2 ms 8636 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Runtime error 13 ms 21300 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -