Submission #1014920

# Submission time Handle Problem Language Result Execution time Memory
1014920 2024-07-05T17:50:53 Z MarwenElarbi Horses (IOI15_horses) C++17
0 / 100
116 ms 49236 KB
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
#define ll long long
#define pb push_back
#define se second
#define fi first
const int MOD=1e9+7;
const int nax=5e5+5;
struct horse{
    int x,y,A;
    double X,Y,m;
};
horse segtree[nax*4];
int n;
void update(int pos,int l,int r,int idx,int x,int y){
    if(l>idx||r<idx) return;
    if(l==r){
        if(x){
            segtree[pos].X=log10(x);
            segtree[pos].x=x;
        }if(y){
            segtree[pos].Y=log10(y);
            segtree[pos].y=y;
        }
        segtree[pos].m=segtree[pos].X+segtree[pos].Y;
        segtree[pos].A=x*y%MOD;
        return;
    }
    int mid=(r+l)/2;
    update(pos*2+1,l,mid,idx,x,y);
    update(pos*2+2,mid+1,r,idx,x,y);
    if(segtree[pos*2+1].m<segtree[pos*2+2].m+segtree[pos*2+1].X){
        segtree[pos].m=segtree[pos*2+2].m+segtree[pos*2+1].X;
        segtree[pos].A=segtree[pos*2+2].A*segtree[pos*2+1].x%MOD;
    }else{
        segtree[pos].m=segtree[pos*2+1].m;
        segtree[pos].A=segtree[pos*2+1].A;
    }
}
int init(int N, int X[], int Y[]){
    n=N;
    for (int i = 0; i < N; ++i)
    {
        update(0,0,n-1,i,X[i],Y[i]);
    }
    return segtree[0].A;
}

int updateX(int pos, int val){
    update(0,0,n-1,pos,val,0);
    return segtree[0].A;
}

int updateY(int pos, int val) {
    update(0,0,n-1,pos,0,val);
    return segtree[0].A;
}

/*
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    
    int N; cin>>N;

    int *X = (int*)malloc(sizeof(int)*(unsigned int)N);
    int *Y = (int*)malloc(sizeof(int)*(unsigned int)N);

    for (int i = 0; i < N; i++) {
        cin>>X[i];
    }

    for (int i = 0; i < N; i++) {
        cin>>Y[i];
    }   

    cout <<init(N,X,Y)<<" ";

    int M; cin>>M;

    for (int i = 0; i < M; i++) {
        int type; cin>>type; 
        int pos; cin>>pos;
        int val; cin>>val; 

        if (type == 1) {
            cout <<updateX(pos,val)<<" ";
        } else if (type == 2) {
            cout <<updateY(pos,val)<<" ";
        }
    }

    return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 116 ms 49236 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -