# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080145 | 2024-08-29T07:25:43 Z | Trumling | Horses (IOI15_horses) | C++14 | 1500 ms | 17848 KB |
#include "horses.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define all(x) x.begin(),x.end() #define INF 9999999999999999 #define MOD 1000000007 typedef long long ll; ll n; ll sell; vector<int>x,y; ll seg[2000001]; void build(int idx,int l,int r) { if(l==r) { seg[idx]=x[l]; return ; } build(idx*2,l,(l+r)/2); build(idx*2+1,(l+r)/2+1,r); seg[idx]=(seg[idx*2]*seg[idx*2+1])%MOD; } void update(int idx,int l,int r,int p) { if(r<p || l>p) return ; if(l==r) { seg[idx]=x[p]; return ; } build(idx*2,l,(l+r)/2); build(idx*2+1,(l+r)/2+1,r); seg[idx]=(seg[idx*2]*seg[idx*2+1])%MOD; } ll query(int idx,int L,int R,int l,int r) { if(r<L || l>R) return 1; if(L<=l && r<=R) return seg[idx]; return (query(idx*2,L,R,l,(l+r)/2)*query(idx*2+1,L,R,(l+r)/2+1,r))%MOD; } int init(int N, int X[], int Y[]) { n=N; for(int i=0;i<n;i++) { x.pb(X[i]); y.pb(Y[i]); } build(1,0,n-1); sell=n-1; ll curr=1; for(int i=n-1;i>=0;i--) { if(y[sell]*curr < y[i]) { sell=i; curr=1; } curr*=x[i]; if(curr*y[sell]>=MOD) break; } return (query(1,0,sell,0,n-1)*y[sell])%MOD; } int updateX(int pos, int val) { x[pos]=val; update(1,0,n-1,pos); sell=n-1; ll curr=1; for(int i=n-1;i>=0;i--) { if(y[sell]*curr < y[i]) { sell=i; curr=1; } curr*=x[i]; if(curr*y[sell]>=MOD) break; } return (query(1,0,sell,0,n-1)*y[sell])%MOD; } int updateY(int pos, int val) { y[pos]=val; sell=n-1; ll curr=1; for(int i=n-1;i>=0;i--) { if(y[sell]*curr < y[i]) { sell=i; curr=1; } curr*=x[i]; if(curr*y[sell]>=MOD) break; } return (query(1,0,sell,0,n-1)*y[sell])%MOD; }
Compilation message
# | 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 | 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 | 1 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 |
# | 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 | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 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 | 1 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 | 3 ms | 348 KB | Output is correct |
24 | Correct | 3 ms | 348 KB | Output is correct |
25 | Correct | 5 ms | 348 KB | Output is correct |
26 | Correct | 4 ms | 344 KB | Output is correct |
27 | Correct | 4 ms | 348 KB | Output is correct |
28 | Correct | 7 ms | 348 KB | Output is correct |
29 | Correct | 9 ms | 348 KB | Output is correct |
30 | Correct | 7 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 348 KB | Output is correct |
32 | Correct | 5 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 17848 KB | Output is correct |
2 | Execution timed out | 1575 ms | 16724 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 600 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 600 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 | 1 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 | 344 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 | 344 KB | Output is correct |
22 | Correct | 1 ms | 344 KB | Output is correct |
23 | Correct | 4 ms | 488 KB | Output is correct |
24 | Correct | 4 ms | 348 KB | Output is correct |
25 | Correct | 4 ms | 348 KB | Output is correct |
26 | Correct | 4 ms | 348 KB | Output is correct |
27 | Correct | 4 ms | 484 KB | Output is correct |
28 | Correct | 7 ms | 484 KB | Output is correct |
29 | Correct | 8 ms | 480 KB | Output is correct |
30 | Correct | 7 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 344 KB | Output is correct |
32 | Correct | 5 ms | 480 KB | Output is correct |
33 | Execution timed out | 1595 ms | 16876 KB | Time limit exceeded |
34 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 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 | 1 ms | 344 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 | 344 KB | Output is correct |
21 | Correct | 0 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 3 ms | 492 KB | Output is correct |
24 | Correct | 3 ms | 348 KB | Output is correct |
25 | Correct | 4 ms | 348 KB | Output is correct |
26 | Correct | 4 ms | 348 KB | Output is correct |
27 | Correct | 4 ms | 484 KB | Output is correct |
28 | Correct | 6 ms | 484 KB | Output is correct |
29 | Correct | 8 ms | 348 KB | Output is correct |
30 | Correct | 11 ms | 484 KB | Output is correct |
31 | Correct | 3 ms | 348 KB | Output is correct |
32 | Correct | 5 ms | 348 KB | Output is correct |
33 | Correct | 54 ms | 17712 KB | Output is correct |
34 | Execution timed out | 1572 ms | 16956 KB | Time limit exceeded |
35 | Halted | 0 ms | 0 KB | - |