# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
262424 |
2020-08-12T22:09:59 Z |
amiratou |
Horses (IOI15_horses) |
C++14 |
|
464 ms |
95864 KB |
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
const int MOD = 1000000007;
typedef pair<long double,ll> ii;
ll x[500005],y[500005];
int n;
ii st[2000005],A[500005],lazy[2000005];
void mod(ll& a){
if(a>=MOD)a%=MOD;
}
int binpow(ll a,ll b){
if(!b)return 1;
ll res=binpow(a,b/2);
res*=res;
mod(res);
if(b&1)res*=a,mod(res);
return (int)res;
}
void build(int node,int l,int r){
lazy[node]={0,1};
if(l==r){
st[node]={A[l].fi+log(y[l]),A[l].se*y[l]};
mod(st[node].se);
return;
}
int med=(l+r)>>1;
build(node*2,l,med),build(node*2+1,med+1,r);
st[node]=max(st[node*2],st[node*2+1]);
}
void prop(int node,int l,int r){
if(lazy[node].fi){
st[node].fi+=lazy[node].fi;
st[node].se*=lazy[node].se;
mod(st[node].se);
if(l!=r){
lazy[node*2].fi+=lazy[node].fi;
lazy[node*2+1].fi+=lazy[node].fi;
lazy[node*2].se*=lazy[node].se;
lazy[node*2+1].se*=lazy[node].se;
mod(lazy[node*2].se),mod(lazy[node*2+1].se);
}
lazy[node]={0,1};
}
}
void updx(int node,int l,int r,int i,int j,ii val){
prop(node,l,r);
if(l>j || r<i)
return;
if(l>=i && r<=j){
lazy[node]=val;
prop(node,l,r);
return;
}
int med=(l+r)>>1;
updx(node*2,l,med,i,j,val),updx(node*2+1,med+1,r,i,j,val);
st[node]=max(st[node*2],st[node*2+1]);
}
void updy(int node,int l,int r,int idx,ii val){
prop(node,l,r);
if(l>idx || r<idx)
return;
if(l==r){
st[node].fi+=val.fi;
st[node].se*=val.se;
mod(st[node].se);
return;
}
int med=(l+r)>>1;
updy(node*2,l,med,idx,val),updy(node*2+1,med+1,r,idx,val);
st[node]=max(st[node*2],st[node*2+1]);
}
int init(int N, int X[], int Y[]) {
n=N;
for (int i = 0; i < N; ++i){
x[i]=X[i],y[i]=Y[i];
A[i].fi=log(x[i]);
if(i)A[i].fi+=A[i-1].fi;
A[i].se=x[i];
if(i)A[i].se*=A[i-1].se,mod(A[i].se);
}
build(1,0,n-1);
return (int)(st[1].se);
}
int updateX(int pos, int val) {
ii h={-log(x[pos]),binpow(x[pos],MOD-2)};
x[pos]=val;
h.fi+=log(val),h.se*=val;
mod(h.se);
updx(1,0,n-1,pos,n-1,h);
prop(1,0,n-1);
return (int)st[1].se;
}
int updateY(int pos, int val) {
ii h={-log(y[pos]),binpow(y[pos],MOD-2)};
y[pos]=val;
h.fi+=log(val),h.se*=val;
mod(h.se);
updy(1,0,n-1,pos,h);
prop(1,0,n-1);
return (int)st[1].se;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
0 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
213 ms |
95864 KB |
Output is correct |
2 |
Correct |
459 ms |
95240 KB |
Output is correct |
3 |
Correct |
400 ms |
95224 KB |
Output is correct |
4 |
Correct |
441 ms |
95224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
544 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
512 KB |
Output is correct |
33 |
Correct |
144 ms |
94200 KB |
Output is correct |
34 |
Correct |
144 ms |
94328 KB |
Output is correct |
35 |
Correct |
162 ms |
94204 KB |
Output is correct |
36 |
Correct |
160 ms |
94200 KB |
Output is correct |
37 |
Correct |
106 ms |
94200 KB |
Output is correct |
38 |
Correct |
129 ms |
94200 KB |
Output is correct |
39 |
Correct |
99 ms |
94228 KB |
Output is correct |
40 |
Correct |
132 ms |
94328 KB |
Output is correct |
41 |
Correct |
92 ms |
94380 KB |
Output is correct |
42 |
Correct |
93 ms |
94328 KB |
Output is correct |
43 |
Correct |
115 ms |
94200 KB |
Output is correct |
44 |
Correct |
117 ms |
94200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
1 ms |
512 KB |
Output is correct |
33 |
Correct |
209 ms |
95408 KB |
Output is correct |
34 |
Correct |
464 ms |
95352 KB |
Output is correct |
35 |
Correct |
437 ms |
95200 KB |
Output is correct |
36 |
Correct |
449 ms |
95224 KB |
Output is correct |
37 |
Correct |
151 ms |
94360 KB |
Output is correct |
38 |
Correct |
142 ms |
94328 KB |
Output is correct |
39 |
Correct |
160 ms |
94200 KB |
Output is correct |
40 |
Correct |
160 ms |
94200 KB |
Output is correct |
41 |
Correct |
106 ms |
94264 KB |
Output is correct |
42 |
Correct |
129 ms |
94328 KB |
Output is correct |
43 |
Correct |
96 ms |
94200 KB |
Output is correct |
44 |
Correct |
132 ms |
94328 KB |
Output is correct |
45 |
Correct |
88 ms |
94204 KB |
Output is correct |
46 |
Correct |
89 ms |
94328 KB |
Output is correct |
47 |
Correct |
114 ms |
94200 KB |
Output is correct |
48 |
Correct |
113 ms |
94200 KB |
Output is correct |
49 |
Correct |
413 ms |
95224 KB |
Output is correct |
50 |
Correct |
407 ms |
95216 KB |
Output is correct |
51 |
Correct |
256 ms |
95096 KB |
Output is correct |
52 |
Correct |
263 ms |
95020 KB |
Output is correct |
53 |
Correct |
340 ms |
95216 KB |
Output is correct |
54 |
Correct |
258 ms |
94968 KB |
Output is correct |
55 |
Correct |
223 ms |
94220 KB |
Output is correct |
56 |
Correct |
298 ms |
94968 KB |
Output is correct |
57 |
Correct |
187 ms |
94840 KB |
Output is correct |
58 |
Correct |
219 ms |
94968 KB |
Output is correct |
59 |
Correct |
129 ms |
93948 KB |
Output is correct |