# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1014050 |
2024-07-04T10:04:35 Z |
Error404 |
Horses (IOI15_horses) |
C++17 |
|
136 ms |
53840 KB |
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define f first
#define s second
#define pi pair<ll,ll>
#define vi vector<ll>
#define vd vector<double>
#define vpi vector<pi>
#define pb push_back
#define INF 1e18
#define endl '\n'
//#define int ll
#define pii pair<pi,ll>
const int mod = 1e9+7;
vd x, y;
vi ox, oy;
const int MAX = 500000;
int n;
struct dt {
double sum, pref;
ll mulx,ans;
};
dt t[MAX*4];
dt make_data(int i){
dt a;
a.sum = x[i];
a.mulx = ox[i];
a.pref = x[i] + y[i];
a.ans = (ox[i]*oy[i])%mod;
return a;
}
dt combine(dt a, dt b){
dt hold;
hold.sum = a.sum+ b.sum;
hold.mulx = ((a.mulx % mod) * (b.mulx % mod))%mod;
if(a.pref > a.sum+b.pref){
hold.pref = a.pref;
hold.ans = a.ans;
}
else{
hold.pref = a.sum + b.pref;
hold.ans = (a.mulx * b.ans)%mod;
}
return hold;
}
void build(int v,int l,int r){
if(l==r){
t[v] = make_data(l);
return;
}
int m = (l+r)/2;
build(v*2,l,m);
build(v*2+1,m+1,r);
t[v] = combine(t[v*2],t[v*2+1]);
}
void update(int v, int l,int r, int pos){
if(l==r){
t[v]= make_data(l);
return;
}
int m = (l+r)/2;
if(pos<=m) update(v*2,l,m,pos);
else update(v*2+1,m+1,r,pos);
t[v] = combine(t[v*2],t[v*2+1]);
}
int init(int N, int a[], int b[]){
n = N;
x.resize(n+1);
y.resize(n+1);
ox.resize(n+1);
oy.resize(n+1);
x[0]=0;
y[0]=0;
for(int i =1 ; i <= n; i++){
ox[i] = a[i-1];
oy[i] = b[i-1];
x[i] =log10(ox[i]);
y[i] = log10(oy[i]);
}
build(1,1,n);
return (t[1].ans%mod);
}
int updateX(int pos,int val){
pos ++;
x[pos] = log10(val);
ox[pos]= val;
update(1,1,n,pos);
return (t[1].ans%mod);
}
int updateY(int pos,int val){
pos++;
y[pos] = log10(val);
oy[pos] = val;
update(1,1,n,pos);
return (t[1].ans%mod);
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:97:21: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
97 | return (t[1].ans%mod);
| ~~~~~~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:106:21: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
106 | return (t[1].ans%mod);
| ~~~~~~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:114:21: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
114 | return (t[1].ans%mod);
| ~~~~~~~~~^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 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 |
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 |
# |
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 |
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 |
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 |
344 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
53660 KB |
Output is correct |
2 |
Correct |
125 ms |
53728 KB |
Output is correct |
3 |
Correct |
122 ms |
53724 KB |
Output is correct |
4 |
Correct |
107 ms |
53588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
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 |
436 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 |
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 |
0 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 |
480 KB |
Output is correct |
33 |
Correct |
54 ms |
52916 KB |
Output is correct |
34 |
Correct |
51 ms |
52776 KB |
Output is correct |
35 |
Correct |
63 ms |
52820 KB |
Output is correct |
36 |
Correct |
83 ms |
52820 KB |
Output is correct |
37 |
Correct |
41 ms |
52816 KB |
Output is correct |
38 |
Correct |
48 ms |
52712 KB |
Output is correct |
39 |
Correct |
35 ms |
52816 KB |
Output is correct |
40 |
Correct |
67 ms |
52912 KB |
Output is correct |
41 |
Correct |
33 ms |
52824 KB |
Output is correct |
42 |
Correct |
38 ms |
52920 KB |
Output is correct |
43 |
Correct |
52 ms |
52608 KB |
Output is correct |
44 |
Correct |
54 ms |
52820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
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 |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 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 |
600 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 |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
33 |
Correct |
72 ms |
53724 KB |
Output is correct |
34 |
Correct |
136 ms |
53804 KB |
Output is correct |
35 |
Correct |
103 ms |
53584 KB |
Output is correct |
36 |
Correct |
106 ms |
53584 KB |
Output is correct |
37 |
Correct |
55 ms |
52816 KB |
Output is correct |
38 |
Correct |
55 ms |
52816 KB |
Output is correct |
39 |
Correct |
72 ms |
52820 KB |
Output is correct |
40 |
Correct |
72 ms |
52820 KB |
Output is correct |
41 |
Correct |
44 ms |
52820 KB |
Output is correct |
42 |
Correct |
50 ms |
52912 KB |
Output is correct |
43 |
Correct |
39 ms |
52820 KB |
Output is correct |
44 |
Correct |
55 ms |
52872 KB |
Output is correct |
45 |
Correct |
39 ms |
52940 KB |
Output is correct |
46 |
Correct |
40 ms |
52876 KB |
Output is correct |
47 |
Correct |
60 ms |
52768 KB |
Output is correct |
48 |
Correct |
53 ms |
52820 KB |
Output is correct |
49 |
Correct |
136 ms |
53584 KB |
Output is correct |
50 |
Correct |
113 ms |
53808 KB |
Output is correct |
51 |
Correct |
103 ms |
53840 KB |
Output is correct |
52 |
Correct |
99 ms |
53840 KB |
Output is correct |
53 |
Correct |
99 ms |
53584 KB |
Output is correct |
54 |
Correct |
81 ms |
53584 KB |
Output is correct |
55 |
Correct |
67 ms |
52816 KB |
Output is correct |
56 |
Correct |
88 ms |
53584 KB |
Output is correct |
57 |
Correct |
67 ms |
53584 KB |
Output is correct |
58 |
Correct |
85 ms |
53732 KB |
Output is correct |
59 |
Correct |
53 ms |
52672 KB |
Output is correct |