# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
414660 | 2021-05-31T02:13:10 Z | ja_kingy | Horses (IOI15_horses) | C++14 | 426 ms | 53340 KB |
#include "horses.h" #include <bits/stdc++.h> using namespace std; set<int> xge2; const int mxN = 5e5, SZ = 1<<19, MOD = 1e9+7; struct ST { int sz; vector<int> mul, mx; ST (int sz) : sz(sz), mul(2*sz, 1), mx(2*sz){} int qmx(int l, int r) { int res = 0; for (l += sz, r += sz; l < r; l/=2, r/=2) { if (l&1) res = max(res, mx[l++]); if (r&1) res = max(res, mx[--r]); } return res; } int qmul(int l, int r) { int res = 1; for (l += sz, r += sz; l < r; l/=2, r/=2) { if (l&1) res = (long long)res*mul[l++]%MOD; if (r&1) res = (long long)res*mul[--r]%MOD; } return res; } void umul(int x, int v) { x += sz; mul[x] = v; for (; x /= 2;) mul[x] = (long long)mul[x*2]*mul[x*2+1]%MOD; } void umx(int x, int v) { x += sz; mx[x] = v; for (; x /= 2;) mx[x] = max(mx[x*2], mx[x*2+1]); } } st(SZ); int n, x[mxN], y[mxN]; int ans() { long long val = 0, pos = n; for (auto it = xge2.end(); it != xge2.begin();) { it--; val = x[*it] * max((long long)st.qmx(*it, pos), val); pos = *it; if (val > MOD) break; } val = max(val, (long long)st.mx[1]); return val%MOD*st.qmul(0, pos)%MOD; } int init(int N, int X[], int Y[]) { n = N; for (int i = 0; i < N; ++i) { if (X[i] >= 2) xge2.insert(i); st.umul(i, X[i]); st.umx(i, Y[i]); } copy(X, X+N, x); copy(Y, Y+N, y); return ans(); } int updateX(int pos, int val) { if (val == 1) xge2.erase(pos); else xge2.insert(pos); st.umul(pos, x[pos]=val); return ans(); } int updateY(int pos, int val) { st.umx(pos, y[pos]=val); return ans(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8524 KB | Output is correct |
2 | Correct | 5 ms | 8524 KB | Output is correct |
3 | Correct | 5 ms | 8524 KB | Output is correct |
4 | Correct | 5 ms | 8524 KB | Output is correct |
5 | Correct | 5 ms | 8532 KB | Output is correct |
6 | Correct | 5 ms | 8524 KB | Output is correct |
7 | Correct | 5 ms | 8532 KB | Output is correct |
8 | Correct | 5 ms | 8524 KB | Output is correct |
9 | Correct | 5 ms | 8524 KB | Output is correct |
10 | Correct | 5 ms | 8524 KB | Output is correct |
11 | Correct | 5 ms | 8524 KB | Output is correct |
12 | Correct | 5 ms | 8432 KB | Output is correct |
13 | Correct | 5 ms | 8524 KB | Output is correct |
14 | Correct | 5 ms | 8524 KB | Output is correct |
15 | Correct | 5 ms | 8524 KB | Output is correct |
16 | Correct | 5 ms | 8524 KB | Output is correct |
17 | Correct | 5 ms | 8524 KB | Output is correct |
18 | Correct | 5 ms | 8524 KB | Output is correct |
19 | Correct | 5 ms | 8528 KB | Output is correct |
20 | Correct | 7 ms | 8524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 8464 KB | Output is correct |
2 | Correct | 7 ms | 8452 KB | Output is correct |
3 | Correct | 5 ms | 8524 KB | Output is correct |
4 | Correct | 6 ms | 8524 KB | Output is correct |
5 | Correct | 5 ms | 8524 KB | Output is correct |
6 | Correct | 5 ms | 8524 KB | Output is correct |
7 | Correct | 5 ms | 8524 KB | Output is correct |
8 | Correct | 5 ms | 8528 KB | Output is correct |
9 | Correct | 5 ms | 8524 KB | Output is correct |
10 | Correct | 6 ms | 8524 KB | Output is correct |
11 | Correct | 5 ms | 8524 KB | Output is correct |
12 | Correct | 5 ms | 8532 KB | Output is correct |
13 | Correct | 6 ms | 8524 KB | Output is correct |
14 | Correct | 5 ms | 8532 KB | Output is correct |
15 | Correct | 6 ms | 8524 KB | Output is correct |
16 | Correct | 5 ms | 8524 KB | Output is correct |
17 | Correct | 5 ms | 8488 KB | Output is correct |
18 | Correct | 5 ms | 8524 KB | Output is correct |
19 | Correct | 7 ms | 8524 KB | Output is correct |
20 | Correct | 6 ms | 8524 KB | Output is correct |
21 | Correct | 6 ms | 8524 KB | Output is correct |
22 | Correct | 5 ms | 8532 KB | Output is correct |
23 | Correct | 6 ms | 8524 KB | Output is correct |
24 | Correct | 6 ms | 8524 KB | Output is correct |
25 | Correct | 6 ms | 8524 KB | Output is correct |
26 | Correct | 8 ms | 8572 KB | Output is correct |
27 | Correct | 8 ms | 8564 KB | Output is correct |
28 | Correct | 6 ms | 8580 KB | Output is correct |
29 | Correct | 6 ms | 8524 KB | Output is correct |
30 | Correct | 6 ms | 8524 KB | Output is correct |
31 | Correct | 6 ms | 8548 KB | Output is correct |
32 | Correct | 6 ms | 8524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 316 ms | 44636 KB | Output is correct |
2 | Correct | 401 ms | 53340 KB | Output is correct |
3 | Correct | 374 ms | 44528 KB | Output is correct |
4 | Correct | 424 ms | 48380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 8516 KB | Output is correct |
2 | Correct | 6 ms | 8524 KB | Output is correct |
3 | Correct | 5 ms | 8524 KB | Output is correct |
4 | Correct | 6 ms | 8424 KB | Output is correct |
5 | Correct | 5 ms | 8524 KB | Output is correct |
6 | Correct | 5 ms | 8532 KB | Output is correct |
7 | Correct | 5 ms | 8532 KB | Output is correct |
8 | Correct | 5 ms | 8468 KB | Output is correct |
9 | Correct | 6 ms | 8524 KB | Output is correct |
10 | Correct | 5 ms | 8524 KB | Output is correct |
11 | Correct | 5 ms | 8532 KB | Output is correct |
12 | Correct | 6 ms | 8528 KB | Output is correct |
13 | Correct | 5 ms | 8508 KB | Output is correct |
14 | Correct | 5 ms | 8524 KB | Output is correct |
15 | Correct | 5 ms | 8528 KB | Output is correct |
16 | Correct | 6 ms | 8524 KB | Output is correct |
17 | Correct | 5 ms | 8524 KB | Output is correct |
18 | Correct | 5 ms | 8524 KB | Output is correct |
19 | Correct | 5 ms | 8528 KB | Output is correct |
20 | Correct | 5 ms | 8524 KB | Output is correct |
21 | Correct | 5 ms | 8524 KB | Output is correct |
22 | Correct | 5 ms | 8524 KB | Output is correct |
23 | Correct | 6 ms | 8592 KB | Output is correct |
24 | Correct | 6 ms | 8600 KB | Output is correct |
25 | Correct | 6 ms | 8524 KB | Output is correct |
26 | Correct | 6 ms | 8524 KB | Output is correct |
27 | Correct | 6 ms | 8524 KB | Output is correct |
28 | Correct | 6 ms | 8592 KB | Output is correct |
29 | Correct | 6 ms | 8524 KB | Output is correct |
30 | Correct | 6 ms | 8524 KB | Output is correct |
31 | Correct | 6 ms | 8544 KB | Output is correct |
32 | Correct | 6 ms | 8524 KB | Output is correct |
33 | Correct | 138 ms | 20552 KB | Output is correct |
34 | Correct | 137 ms | 20452 KB | Output is correct |
35 | Correct | 298 ms | 50756 KB | Output is correct |
36 | Correct | 306 ms | 50664 KB | Output is correct |
37 | Correct | 136 ms | 18564 KB | Output is correct |
38 | Correct | 200 ms | 31376 KB | Output is correct |
39 | Correct | 129 ms | 18444 KB | Output is correct |
40 | Correct | 294 ms | 45792 KB | Output is correct |
41 | Correct | 131 ms | 18448 KB | Output is correct |
42 | Correct | 130 ms | 18512 KB | Output is correct |
43 | Correct | 301 ms | 46300 KB | Output is correct |
44 | Correct | 292 ms | 46148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8532 KB | Output is correct |
2 | Correct | 5 ms | 8532 KB | Output is correct |
3 | Correct | 5 ms | 8524 KB | Output is correct |
4 | Correct | 5 ms | 8524 KB | Output is correct |
5 | Correct | 5 ms | 8524 KB | Output is correct |
6 | Correct | 5 ms | 8524 KB | Output is correct |
7 | Correct | 5 ms | 8528 KB | Output is correct |
8 | Correct | 5 ms | 8524 KB | Output is correct |
9 | Correct | 5 ms | 8528 KB | Output is correct |
10 | Correct | 7 ms | 8524 KB | Output is correct |
11 | Correct | 5 ms | 8532 KB | Output is correct |
12 | Correct | 5 ms | 8524 KB | Output is correct |
13 | Correct | 6 ms | 8524 KB | Output is correct |
14 | Correct | 6 ms | 8536 KB | Output is correct |
15 | Correct | 5 ms | 8524 KB | Output is correct |
16 | Correct | 6 ms | 8532 KB | Output is correct |
17 | Correct | 5 ms | 8532 KB | Output is correct |
18 | Correct | 6 ms | 8460 KB | Output is correct |
19 | Correct | 6 ms | 8480 KB | Output is correct |
20 | Correct | 5 ms | 8524 KB | Output is correct |
21 | Correct | 5 ms | 8524 KB | Output is correct |
22 | Correct | 5 ms | 8524 KB | Output is correct |
23 | Correct | 6 ms | 8488 KB | Output is correct |
24 | Correct | 5 ms | 8524 KB | Output is correct |
25 | Correct | 6 ms | 8544 KB | Output is correct |
26 | Correct | 6 ms | 8524 KB | Output is correct |
27 | Correct | 6 ms | 8524 KB | Output is correct |
28 | Correct | 6 ms | 8524 KB | Output is correct |
29 | Correct | 7 ms | 8524 KB | Output is correct |
30 | Correct | 6 ms | 8524 KB | Output is correct |
31 | Correct | 6 ms | 8548 KB | Output is correct |
32 | Correct | 6 ms | 8524 KB | Output is correct |
33 | Correct | 340 ms | 44708 KB | Output is correct |
34 | Correct | 406 ms | 53316 KB | Output is correct |
35 | Correct | 369 ms | 44588 KB | Output is correct |
36 | Correct | 426 ms | 48388 KB | Output is correct |
37 | Correct | 141 ms | 20456 KB | Output is correct |
38 | Correct | 140 ms | 20448 KB | Output is correct |
39 | Correct | 336 ms | 50672 KB | Output is correct |
40 | Correct | 324 ms | 50732 KB | Output is correct |
41 | Correct | 136 ms | 18632 KB | Output is correct |
42 | Correct | 203 ms | 31428 KB | Output is correct |
43 | Correct | 129 ms | 18372 KB | Output is correct |
44 | Correct | 294 ms | 45892 KB | Output is correct |
45 | Correct | 125 ms | 18436 KB | Output is correct |
46 | Correct | 138 ms | 18500 KB | Output is correct |
47 | Correct | 305 ms | 46148 KB | Output is correct |
48 | Correct | 298 ms | 46152 KB | Output is correct |
49 | Correct | 203 ms | 23544 KB | Output is correct |
50 | Correct | 199 ms | 23492 KB | Output is correct |
51 | Correct | 397 ms | 52624 KB | Output is correct |
52 | Correct | 360 ms | 52192 KB | Output is correct |
53 | Correct | 235 ms | 21700 KB | Output is correct |
54 | Correct | 262 ms | 35296 KB | Output is correct |
55 | Correct | 173 ms | 19396 KB | Output is correct |
56 | Correct | 364 ms | 47576 KB | Output is correct |
57 | Correct | 163 ms | 20036 KB | Output is correct |
58 | Correct | 192 ms | 20540 KB | Output is correct |
59 | Correct | 311 ms | 46176 KB | Output is correct |