Submission #1014929

# Submission time Handle Problem Language Result Execution time Memory
1014929 2024-07-05T18:07:43 Z MarwenElarbi Horses (IOI15_horses) C++17
100 / 100
227 ms 67164 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{
    long long 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=segtree[pos].x*segtree[pos].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);
    segtree[pos].X=segtree[pos*2+1].X+segtree[pos*2+2].X;
    segtree[pos].x=segtree[pos*2+1].x*segtree[pos*2+2].x%MOD;
    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;
}*/

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:49:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   49 |     return segtree[0].A;
      |            ~~~~~~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:54:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   54 |     return segtree[0].A;
      |            ~~~~~~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:59:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   59 |     return segtree[0].A;
      |            ~~~~~~~~~~~^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 440 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 448 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 440 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 440 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 58196 KB Output is correct
2 Correct 200 ms 67156 KB Output is correct
3 Correct 166 ms 58196 KB Output is correct
4 Correct 182 ms 62032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 448 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 440 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 604 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 153 ms 57656 KB Output is correct
34 Correct 150 ms 57572 KB Output is correct
35 Correct 160 ms 64456 KB Output is correct
36 Correct 160 ms 64372 KB Output is correct
37 Correct 130 ms 55632 KB Output is correct
38 Correct 131 ms 56660 KB Output is correct
39 Correct 131 ms 55632 KB Output is correct
40 Correct 138 ms 59432 KB Output is correct
41 Correct 125 ms 55632 KB Output is correct
42 Correct 124 ms 55632 KB Output is correct
43 Correct 131 ms 59736 KB Output is correct
44 Correct 141 ms 59816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 416 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 456 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 456 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 149 ms 58196 KB Output is correct
34 Correct 227 ms 67164 KB Output is correct
35 Correct 188 ms 58224 KB Output is correct
36 Correct 188 ms 62220 KB Output is correct
37 Correct 149 ms 57536 KB Output is correct
38 Correct 142 ms 57520 KB Output is correct
39 Correct 156 ms 64312 KB Output is correct
40 Correct 159 ms 64288 KB Output is correct
41 Correct 127 ms 55636 KB Output is correct
42 Correct 146 ms 56648 KB Output is correct
43 Correct 136 ms 55528 KB Output is correct
44 Correct 138 ms 59572 KB Output is correct
45 Correct 139 ms 55640 KB Output is correct
46 Correct 124 ms 55584 KB Output is correct
47 Correct 141 ms 59728 KB Output is correct
48 Correct 138 ms 59728 KB Output is correct
49 Correct 191 ms 59472 KB Output is correct
50 Correct 210 ms 59476 KB Output is correct
51 Correct 193 ms 66384 KB Output is correct
52 Correct 178 ms 65856 KB Output is correct
53 Correct 183 ms 57936 KB Output is correct
54 Correct 173 ms 58260 KB Output is correct
55 Correct 149 ms 56704 KB Output is correct
56 Correct 184 ms 61228 KB Output is correct
57 Correct 145 ms 57172 KB Output is correct
58 Correct 154 ms 57684 KB Output is correct
59 Correct 144 ms 59960 KB Output is correct