# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
641862 | 2022-09-17T17:15:25 Z | QwertyPi | Horses (IOI15_horses) | C++14 | 1500 ms | 56896 KB |
#include "horses.h" #include <bits/stdc++.h> #define ll long long using namespace std; const ll MOD = 1e9 + 7; const ll MAXN = 5e5 + 11; ll x[MAXN], y[MAXN]; struct BIT{ ll bit[MAXN] = {0}, id; void init(ll id, ll (*f)(ll, ll)) { this->id = id; fill(bit, bit + MAXN, id); combine = f; } void add(ll pos, ll val){ pos++; for(ll i = pos; i < MAXN; i += i & -i){ bit[i] = combine(bit[i], val); } } ll qry(ll pos){ pos++; ll ret = id; for(ll i = pos; i; i -= i & -i){ ret = combine(ret, bit[i]); } return ret; } ll (*combine)(ll, ll); } bit_add, bit_mul; struct RMQ{ }; ll N; set<ll> n1; ll add(ll x, ll y) { return x + y; } ll mul(ll x, ll y) { return x * y % MOD; } ll bp(ll a, ll b) { if(b == 0) return 1; return bp(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD; } ll mi(ll a) { return bp(a, MOD - 2); } ll query() { ll ans = 1, rans = 1; ll c = 1; ll i; for(i = N - 1; i >= 0; i--){ if(i == -1) break; c *= x[i]; if(c > MOD) break; } c = 1; for(; i < N; i++){ if(c * y[i] > ans){ ans = c * y[i]; rans = bit_add.qry(i) > 0 ? 0 : mul(bit_mul.qry(i), y[i]); } c *= x[i + 1]; } return rans; } int init(int N, int X[], int Y[]) { ::N = N; bit_add.init(0, add); bit_mul.init(1, mul); for(int i = 0; i < N; i++) x[i] = X[i]; for(int i = 0; i < N; i++) y[i] = Y[i]; for(int i = 0; i < N; i++){ if(x[i] == MOD) bit_add.add(i, 1); else bit_mul.add(i, x[i]); } for(int i = 0; i < N; i++){ if(x[i] != 1) n1.insert(i); } return query(); } int updateX(int pos, int val) { if(x[pos] == MOD) bit_add.add(pos, -1); else bit_mul.add(pos, mi(x[pos])); if(x[pos] != 1) n1.erase(pos); x[pos] = val; if(x[pos] == MOD) bit_add.add(pos, 1); else bit_mul.add(pos, x[pos]); if(x[pos] != 1) n1.insert(pos); return query(); } int updateY(int pos, int val) { y[pos] = val; return query(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8148 KB | Output is correct |
2 | Correct | 4 ms | 8148 KB | Output is correct |
3 | Correct | 4 ms | 8148 KB | Output is correct |
4 | Correct | 4 ms | 8148 KB | Output is correct |
5 | Correct | 4 ms | 8020 KB | Output is correct |
6 | Correct | 4 ms | 8020 KB | Output is correct |
7 | Correct | 4 ms | 8020 KB | Output is correct |
8 | Correct | 4 ms | 8148 KB | Output is correct |
9 | Correct | 4 ms | 8092 KB | Output is correct |
10 | Correct | 5 ms | 8148 KB | Output is correct |
11 | Correct | 6 ms | 8148 KB | Output is correct |
12 | Correct | 4 ms | 8020 KB | Output is correct |
13 | Correct | 4 ms | 8148 KB | Output is correct |
14 | Correct | 4 ms | 8148 KB | Output is correct |
15 | Correct | 5 ms | 8148 KB | Output is correct |
16 | Correct | 5 ms | 8020 KB | Output is correct |
17 | Correct | 6 ms | 8020 KB | Output is correct |
18 | Correct | 5 ms | 8020 KB | Output is correct |
19 | Correct | 5 ms | 8148 KB | Output is correct |
20 | Correct | 4 ms | 8020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 8148 KB | Output is correct |
2 | Correct | 4 ms | 8020 KB | Output is correct |
3 | Correct | 4 ms | 8148 KB | Output is correct |
4 | Correct | 5 ms | 8020 KB | Output is correct |
5 | Correct | 6 ms | 8148 KB | Output is correct |
6 | Correct | 4 ms | 8148 KB | Output is correct |
7 | Correct | 5 ms | 8020 KB | Output is correct |
8 | Correct | 5 ms | 8148 KB | Output is correct |
9 | Correct | 4 ms | 8020 KB | Output is correct |
10 | Correct | 5 ms | 8020 KB | Output is correct |
11 | Correct | 5 ms | 8020 KB | Output is correct |
12 | Correct | 4 ms | 8148 KB | Output is correct |
13 | Correct | 5 ms | 8020 KB | Output is correct |
14 | Correct | 5 ms | 8148 KB | Output is correct |
15 | Correct | 5 ms | 8020 KB | Output is correct |
16 | Correct | 6 ms | 8148 KB | Output is correct |
17 | Correct | 5 ms | 8136 KB | Output is correct |
18 | Correct | 6 ms | 8148 KB | Output is correct |
19 | Correct | 5 ms | 8020 KB | Output is correct |
20 | Correct | 5 ms | 8148 KB | Output is correct |
21 | Correct | 5 ms | 8148 KB | Output is correct |
22 | Correct | 6 ms | 8148 KB | Output is correct |
23 | Correct | 6 ms | 8148 KB | Output is correct |
24 | Correct | 5 ms | 8196 KB | Output is correct |
25 | Correct | 6 ms | 8216 KB | Output is correct |
26 | Correct | 5 ms | 8148 KB | Output is correct |
27 | Correct | 7 ms | 8148 KB | Output is correct |
28 | Correct | 6 ms | 8148 KB | Output is correct |
29 | Correct | 7 ms | 8148 KB | Output is correct |
30 | Correct | 7 ms | 8224 KB | Output is correct |
31 | Correct | 8 ms | 8160 KB | Output is correct |
32 | Correct | 6 ms | 8152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 186 ms | 44288 KB | Output is correct |
2 | Correct | 279 ms | 44336 KB | Output is correct |
3 | Correct | 270 ms | 48120 KB | Output is correct |
4 | Correct | 383 ms | 51916 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8148 KB | Output is correct |
2 | Correct | 4 ms | 8148 KB | Output is correct |
3 | Correct | 4 ms | 8020 KB | Output is correct |
4 | Correct | 4 ms | 8152 KB | Output is correct |
5 | Correct | 5 ms | 8020 KB | Output is correct |
6 | Correct | 5 ms | 8132 KB | Output is correct |
7 | Correct | 4 ms | 8148 KB | Output is correct |
8 | Correct | 4 ms | 8020 KB | Output is correct |
9 | Correct | 4 ms | 8148 KB | Output is correct |
10 | Correct | 5 ms | 8148 KB | Output is correct |
11 | Correct | 4 ms | 8148 KB | Output is correct |
12 | Correct | 4 ms | 8148 KB | Output is correct |
13 | Correct | 5 ms | 8020 KB | Output is correct |
14 | Correct | 4 ms | 8020 KB | Output is correct |
15 | Correct | 4 ms | 8148 KB | Output is correct |
16 | Correct | 5 ms | 8020 KB | Output is correct |
17 | Correct | 6 ms | 8032 KB | Output is correct |
18 | Correct | 5 ms | 8132 KB | Output is correct |
19 | Correct | 4 ms | 8148 KB | Output is correct |
20 | Correct | 5 ms | 8148 KB | Output is correct |
21 | Correct | 6 ms | 8148 KB | Output is correct |
22 | Correct | 4 ms | 8140 KB | Output is correct |
23 | Correct | 5 ms | 8152 KB | Output is correct |
24 | Correct | 5 ms | 8108 KB | Output is correct |
25 | Correct | 5 ms | 8148 KB | Output is correct |
26 | Correct | 5 ms | 8148 KB | Output is correct |
27 | Correct | 7 ms | 8276 KB | Output is correct |
28 | Correct | 6 ms | 8148 KB | Output is correct |
29 | Correct | 7 ms | 8148 KB | Output is correct |
30 | Correct | 5 ms | 8148 KB | Output is correct |
31 | Correct | 7 ms | 8148 KB | Output is correct |
32 | Correct | 7 ms | 8148 KB | Output is correct |
33 | Correct | 134 ms | 24020 KB | Output is correct |
34 | Correct | 52 ms | 24012 KB | Output is correct |
35 | Correct | 178 ms | 54288 KB | Output is correct |
36 | Correct | 180 ms | 54220 KB | Output is correct |
37 | Correct | 545 ms | 22204 KB | Output is correct |
38 | Correct | 114 ms | 34912 KB | Output is correct |
39 | Execution timed out | 1568 ms | 21836 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8148 KB | Output is correct |
2 | Correct | 4 ms | 8036 KB | Output is correct |
3 | Correct | 4 ms | 8148 KB | Output is correct |
4 | Correct | 5 ms | 8136 KB | Output is correct |
5 | Correct | 4 ms | 8148 KB | Output is correct |
6 | Correct | 4 ms | 8020 KB | Output is correct |
7 | Correct | 5 ms | 8020 KB | Output is correct |
8 | Correct | 4 ms | 8140 KB | Output is correct |
9 | Correct | 4 ms | 8148 KB | Output is correct |
10 | Correct | 4 ms | 8020 KB | Output is correct |
11 | Correct | 4 ms | 8020 KB | Output is correct |
12 | Correct | 4 ms | 8020 KB | Output is correct |
13 | Correct | 4 ms | 8148 KB | Output is correct |
14 | Correct | 4 ms | 8136 KB | Output is correct |
15 | Correct | 4 ms | 8148 KB | Output is correct |
16 | Correct | 4 ms | 8148 KB | Output is correct |
17 | Correct | 4 ms | 8084 KB | Output is correct |
18 | Correct | 4 ms | 8148 KB | Output is correct |
19 | Correct | 4 ms | 8192 KB | Output is correct |
20 | Correct | 4 ms | 8020 KB | Output is correct |
21 | Correct | 4 ms | 8020 KB | Output is correct |
22 | Correct | 4 ms | 8148 KB | Output is correct |
23 | Correct | 5 ms | 8148 KB | Output is correct |
24 | Correct | 5 ms | 8204 KB | Output is correct |
25 | Correct | 6 ms | 8148 KB | Output is correct |
26 | Correct | 5 ms | 8148 KB | Output is correct |
27 | Correct | 7 ms | 8192 KB | Output is correct |
28 | Correct | 5 ms | 8148 KB | Output is correct |
29 | Correct | 8 ms | 8148 KB | Output is correct |
30 | Correct | 6 ms | 8148 KB | Output is correct |
31 | Correct | 7 ms | 8148 KB | Output is correct |
32 | Correct | 7 ms | 8148 KB | Output is correct |
33 | Correct | 195 ms | 48140 KB | Output is correct |
34 | Correct | 292 ms | 56896 KB | Output is correct |
35 | Correct | 266 ms | 48168 KB | Output is correct |
36 | Correct | 389 ms | 51872 KB | Output is correct |
37 | Correct | 126 ms | 24012 KB | Output is correct |
38 | Correct | 49 ms | 24048 KB | Output is correct |
39 | Correct | 192 ms | 54308 KB | Output is correct |
40 | Correct | 183 ms | 54136 KB | Output is correct |
41 | Correct | 543 ms | 22296 KB | Output is correct |
42 | Correct | 105 ms | 34836 KB | Output is correct |
43 | Execution timed out | 1552 ms | 21912 KB | Time limit exceeded |
44 | Halted | 0 ms | 0 KB | - |