# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
310709 | 2020-10-07T16:35:03 Z | keta_tsimakuridze | Horses (IOI15_horses) | C++14 | 421 ms | 63868 KB |
#include "horses.h" #include<bits/stdc++.h> #define ll long long using namespace std; const int N=5e5+5,mod=1e9+7,Mx=1e9; ll x[N],y[N],k,t,m,n; struct node { ll l; ll r; ll Y; ll b; ll bl; ll br; } tree[4*N]; void update(ll u,ll ind,ll l,int r,ll valx,ll valy) { if(l>ind || r<ind) return; if(l==r) { tree[u].l=valx; // tree[u].X=valx; tree[u].Y=valy; tree[u].r=1; if(valx*valy>Mx) { tree[u].b=1; } else tree[u].b=0; return; } int mid=(l+r)/2; update(2*u,ind,l,mid,valx,valy); update(2*u+1,ind,mid+1,r,valx,valy); if(tree[2*u].br||tree[2*u+1].bl || tree[2*u].r*tree[2*u+1].l>Mx || tree[2*u].r*tree[2*u+1].l*tree[2*u+1].Y>tree[2*u].Y ) { // tree[2*u].l*tree[2*u].r*tree[2*u+1].l if(tree[2*u].b||tree[2*u+1].bl || tree[2*u].l*tree[2*u].r*tree[2*u+1].l>Mx) { tree[u].bl=1; } else tree[u].bl=0; tree[u].r=tree[2*u+1].r; tree[u].br=tree[2*u+1].br; tree[u].l=tree[2*u].l*tree[2*u].r%mod*tree[2*u+1].l%mod; if(tree[u].bl || tree[u].br || tree[u].l*tree[u].r>Mx) { tree[u].b=1; } else tree[u].b=0; tree[u].Y=tree[2*u+1].Y; } else { tree[u].l=tree[2*u].l; tree[u].bl=tree[2*u].bl; tree[u].Y=tree[2*u].Y; tree[u].r=tree[2*u+1].r*tree[2*u+1].l%mod*tree[2*u].r%mod; if(tree[2*u+1].b || tree[2*u].br ||tree[2*u+1].r*tree[2*u+1].l*tree[2*u].r>Mx) { tree[u].br=1; } else tree[u].br=0; if(tree[u].br || tree[u].bl || tree[u].l*tree[u].r>Mx) { tree[u].b=1; } else tree[u].b=0; } } void go(int u,int l,int r) { cout<<l<<" "<<r<<" "<<tree[u].l<<" "<<tree[u].r<<" "<<tree[u].Y<<endl; if(l==r) { return; } int mid=(l+r)/2; go(2*u,l,mid); go(2*u+1,mid+1,r); } int init(int nn,int X[],int Y[]) { n=nn; for(k=1; k<=n; k++) { x[k]=X[k-1]; y[k]=Y[k-1]; update(1,k,1,n,x[k],y[k]); } //go(1,1,n); ll ans=tree[1].l*tree[1].Y%mod; return ans; } int updateX(int ind,int c) { ind++; update(1,ind,1,n,c,y[ind]); x[ind]=c; ll ans=tree[1].l*tree[1].Y%mod; return ans; } int updateY(int ind,int c){ ind++; update(1,ind,1,n,x[ind],c); y[ind]=c; ll ans=tree[1].l*tree[1].Y%mod; return ans; }
Compilation message
# | 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 | 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 | 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 | 0 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 | 0 ms | 384 KB | Output is correct |
19 | Correct | 0 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 | 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 | 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 |
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 | 1 ms | 512 KB | Output is correct |
25 | Correct | 1 ms | 512 KB | Output is correct |
26 | Correct | 1 ms | 512 KB | Output is correct |
27 | Correct | 1 ms | 512 KB | Output is correct |
28 | Correct | 1 ms | 512 KB | Output is correct |
29 | Correct | 1 ms | 512 KB | Output is correct |
30 | Correct | 1 ms | 512 KB | Output is correct |
31 | Correct | 1 ms | 512 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 318 ms | 63736 KB | Output is correct |
2 | Correct | 420 ms | 63656 KB | Output is correct |
3 | Correct | 397 ms | 63352 KB | Output is correct |
4 | Correct | 408 ms | 63352 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 | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 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 | 0 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 | 1 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 | 1 ms | 512 KB | Output is correct |
26 | Correct | 1 ms | 512 KB | Output is correct |
27 | Correct | 1 ms | 512 KB | Output is correct |
28 | Correct | 1 ms | 512 KB | Output is correct |
29 | Correct | 1 ms | 512 KB | Output is correct |
30 | Correct | 2 ms | 512 KB | Output is correct |
31 | Correct | 1 ms | 512 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 295 ms | 62868 KB | Output is correct |
34 | Correct | 298 ms | 62444 KB | Output is correct |
35 | Correct | 306 ms | 62328 KB | Output is correct |
36 | Correct | 300 ms | 62328 KB | Output is correct |
37 | Correct | 282 ms | 61816 KB | Output is correct |
38 | Correct | 272 ms | 61716 KB | Output is correct |
39 | Correct | 276 ms | 61816 KB | Output is correct |
40 | Correct | 287 ms | 62328 KB | Output is correct |
41 | Correct | 273 ms | 61816 KB | Output is correct |
42 | Correct | 273 ms | 61868 KB | Output is correct |
43 | Correct | 281 ms | 62360 KB | Output is correct |
44 | Correct | 274 ms | 62200 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 | 0 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 | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 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 | 1 ms | 512 KB | Output is correct |
26 | Correct | 1 ms | 512 KB | Output is correct |
27 | Correct | 2 ms | 512 KB | Output is correct |
28 | Correct | 1 ms | 512 KB | Output is correct |
29 | Correct | 1 ms | 512 KB | Output is correct |
30 | Correct | 2 ms | 512 KB | Output is correct |
31 | Correct | 1 ms | 512 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 320 ms | 62968 KB | Output is correct |
34 | Correct | 421 ms | 63868 KB | Output is correct |
35 | Correct | 402 ms | 63284 KB | Output is correct |
36 | Correct | 408 ms | 63352 KB | Output is correct |
37 | Correct | 300 ms | 62368 KB | Output is correct |
38 | Correct | 298 ms | 62456 KB | Output is correct |
39 | Correct | 298 ms | 62200 KB | Output is correct |
40 | Correct | 294 ms | 62328 KB | Output is correct |
41 | Correct | 281 ms | 61756 KB | Output is correct |
42 | Correct | 271 ms | 61816 KB | Output is correct |
43 | Correct | 268 ms | 61688 KB | Output is correct |
44 | Correct | 278 ms | 62328 KB | Output is correct |
45 | Correct | 271 ms | 61944 KB | Output is correct |
46 | Correct | 277 ms | 61816 KB | Output is correct |
47 | Correct | 274 ms | 62148 KB | Output is correct |
48 | Correct | 281 ms | 62200 KB | Output is correct |
49 | Correct | 416 ms | 63352 KB | Output is correct |
50 | Correct | 420 ms | 63224 KB | Output is correct |
51 | Correct | 349 ms | 63236 KB | Output is correct |
52 | Correct | 343 ms | 63224 KB | Output is correct |
53 | Correct | 406 ms | 63108 KB | Output is correct |
54 | Correct | 331 ms | 63224 KB | Output is correct |
55 | Correct | 324 ms | 61944 KB | Output is correct |
56 | Correct | 334 ms | 63224 KB | Output is correct |
57 | Correct | 321 ms | 62712 KB | Output is correct |
58 | Correct | 333 ms | 62968 KB | Output is correct |
59 | Correct | 276 ms | 62200 KB | Output is correct |