# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
594462 | 2022-07-12T13:29:08 Z | davi_bart | Horses (IOI15_horses) | C++14 | 681 ms | 58716 KB |
#pragma GCC optimize("O3") #include <bits/stdc++.h> #include "horses.h" using namespace std; #define ll long long #define int ll #define fi first #define se second #define ld long double #define pb push_back mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); static const int mod = 1e9 + 7; int pot(int a, int b) { if (b == 0) return 1; int x = pot(a, b / 2); if (b % 2) return x * x % mod * a % mod; return x * x % mod; } struct segment { static const int dim = 1 << 19; struct node { double log = 0; int mod = 1; double lazy_log = 0; int lazy_mod = 1; }; vector<node> s = vector<node>(2 * dim); void prop(int pos) { if (s[pos].lazy_log != 0) { s[pos].log += s[pos].lazy_log; if (pos < dim) { s[2 * pos].lazy_log += s[pos].lazy_log; s[2 * pos + 1].lazy_log += s[pos].lazy_log; } s[pos].lazy_log = 0; } if (s[pos].lazy_mod > 1) { s[pos].mod = s[pos].mod * s[pos].lazy_mod % mod; if (pos < dim) { s[2 * pos].lazy_mod = s[2 * pos].lazy_mod * s[pos].lazy_mod % mod; s[2 * pos + 1].lazy_mod = s[2 * pos + 1].lazy_mod * s[pos].lazy_mod % mod; } s[pos].lazy_mod = 1; } } void upd(int pos, int l, int r, int a, int b, double log_, int mod_) { prop(pos); if (b < l || r < a) return; if (a <= l && r <= b) { s[pos].lazy_log += log_; s[pos].lazy_mod = s[pos].lazy_mod * mod_ % mod; prop(pos); return; } int m = (l + r) / 2; upd(2 * pos, l, m, a, b, log_, mod_); upd(2 * pos + 1, m + 1, r, a, b, log_, mod_); if (s[2 * pos].log > s[2 * pos + 1].log) s[pos] = s[2 * pos]; else s[pos] = s[2 * pos + 1]; } void upd(int a, int b, double log_, int mod_) { upd(1, 0, dim - 1, a, b, log_, mod_); } int query() { prop(1); // cout << s[1].log << " " << s[1].lazy_mod << " " << s[1].lazy_log << endl; return s[1].mod; } } seg; vector<int> X, Y; int N; int calc() { int ma = 0; int cur = 1; for (int i = 0; i < N; i++) { cur *= X[i]; ma = max(ma, cur * Y[i] % mod); } return ma; } signed init(signed N, signed x[], signed y[]) { ::N = N; for (int i = 0; i < N; i++) { X.pb(x[i]); Y.pb(y[i]); seg.upd(i, N, log(X[i]), X[i]); seg.upd(i, i, log(Y[i]), Y[i]); } return seg.query(); } signed updateX(signed pos, signed val) { seg.upd(pos, N, -log(X[pos]) + log(val), val * pot(X[pos], mod - 2) % mod); X[pos] = val; // seg.upd(pos, N, log(val), val); return seg.query(); } signed updateY(signed pos, signed val) { seg.upd(pos, pos, -log(Y[pos]) + log(val), pot(Y[pos], mod - 2) * val % mod); Y[pos] = val; // seg.upd(pos, pos, log(val), val); return seg.query(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 33108 KB | Output is correct |
2 | Correct | 13 ms | 33120 KB | Output is correct |
3 | Correct | 13 ms | 33144 KB | Output is correct |
4 | Correct | 13 ms | 33092 KB | Output is correct |
5 | Correct | 13 ms | 33124 KB | Output is correct |
6 | Correct | 13 ms | 33116 KB | Output is correct |
7 | Correct | 15 ms | 33108 KB | Output is correct |
8 | Correct | 13 ms | 33108 KB | Output is correct |
9 | Correct | 13 ms | 33108 KB | Output is correct |
10 | Correct | 14 ms | 33152 KB | Output is correct |
11 | Correct | 13 ms | 33108 KB | Output is correct |
12 | Correct | 14 ms | 33148 KB | Output is correct |
13 | Correct | 14 ms | 33056 KB | Output is correct |
14 | Correct | 15 ms | 33136 KB | Output is correct |
15 | Correct | 15 ms | 33108 KB | Output is correct |
16 | Correct | 15 ms | 33108 KB | Output is correct |
17 | Correct | 14 ms | 33108 KB | Output is correct |
18 | Correct | 13 ms | 33108 KB | Output is correct |
19 | Correct | 13 ms | 33108 KB | Output is correct |
20 | Correct | 13 ms | 33108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 33128 KB | Output is correct |
2 | Correct | 13 ms | 33120 KB | Output is correct |
3 | Correct | 14 ms | 33116 KB | Output is correct |
4 | Correct | 13 ms | 33056 KB | Output is correct |
5 | Correct | 16 ms | 33144 KB | Output is correct |
6 | Correct | 13 ms | 33084 KB | Output is correct |
7 | Correct | 13 ms | 33108 KB | Output is correct |
8 | Correct | 15 ms | 33112 KB | Output is correct |
9 | Correct | 17 ms | 33108 KB | Output is correct |
10 | Correct | 14 ms | 33108 KB | Output is correct |
11 | Correct | 14 ms | 33100 KB | Output is correct |
12 | Correct | 18 ms | 33088 KB | Output is correct |
13 | Correct | 14 ms | 33108 KB | Output is correct |
14 | Correct | 15 ms | 33108 KB | Output is correct |
15 | Correct | 13 ms | 33132 KB | Output is correct |
16 | Correct | 14 ms | 33028 KB | Output is correct |
17 | Correct | 15 ms | 33108 KB | Output is correct |
18 | Correct | 14 ms | 33108 KB | Output is correct |
19 | Correct | 14 ms | 33048 KB | Output is correct |
20 | Correct | 14 ms | 33108 KB | Output is correct |
21 | Correct | 14 ms | 33132 KB | Output is correct |
22 | Correct | 16 ms | 33156 KB | Output is correct |
23 | Correct | 15 ms | 33140 KB | Output is correct |
24 | Correct | 17 ms | 33172 KB | Output is correct |
25 | Correct | 15 ms | 33168 KB | Output is correct |
26 | Correct | 15 ms | 33128 KB | Output is correct |
27 | Correct | 16 ms | 33164 KB | Output is correct |
28 | Correct | 16 ms | 33108 KB | Output is correct |
29 | Correct | 16 ms | 33156 KB | Output is correct |
30 | Correct | 16 ms | 33288 KB | Output is correct |
31 | Correct | 15 ms | 33160 KB | Output is correct |
32 | Correct | 15 ms | 33108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 458 ms | 47740 KB | Output is correct |
2 | Correct | 590 ms | 58716 KB | Output is correct |
3 | Correct | 559 ms | 49820 KB | Output is correct |
4 | Correct | 556 ms | 53756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 33108 KB | Output is correct |
2 | Correct | 13 ms | 33108 KB | Output is correct |
3 | Correct | 13 ms | 33108 KB | Output is correct |
4 | Correct | 13 ms | 33056 KB | Output is correct |
5 | Correct | 14 ms | 33072 KB | Output is correct |
6 | Correct | 15 ms | 33140 KB | Output is correct |
7 | Correct | 16 ms | 33116 KB | Output is correct |
8 | Correct | 16 ms | 33104 KB | Output is correct |
9 | Correct | 16 ms | 33108 KB | Output is correct |
10 | Correct | 15 ms | 33108 KB | Output is correct |
11 | Correct | 16 ms | 33120 KB | Output is correct |
12 | Correct | 14 ms | 33108 KB | Output is correct |
13 | Correct | 14 ms | 33128 KB | Output is correct |
14 | Correct | 14 ms | 33140 KB | Output is correct |
15 | Correct | 14 ms | 33032 KB | Output is correct |
16 | Correct | 14 ms | 33076 KB | Output is correct |
17 | Correct | 13 ms | 33108 KB | Output is correct |
18 | Correct | 13 ms | 33108 KB | Output is correct |
19 | Correct | 15 ms | 33140 KB | Output is correct |
20 | Correct | 14 ms | 33108 KB | Output is correct |
21 | Correct | 15 ms | 33116 KB | Output is correct |
22 | Correct | 14 ms | 33084 KB | Output is correct |
23 | Correct | 17 ms | 33152 KB | Output is correct |
24 | Correct | 16 ms | 33160 KB | Output is correct |
25 | Correct | 17 ms | 33184 KB | Output is correct |
26 | Correct | 19 ms | 33148 KB | Output is correct |
27 | Correct | 17 ms | 33160 KB | Output is correct |
28 | Correct | 15 ms | 33152 KB | Output is correct |
29 | Correct | 15 ms | 33160 KB | Output is correct |
30 | Correct | 16 ms | 33160 KB | Output is correct |
31 | Correct | 15 ms | 33164 KB | Output is correct |
32 | Correct | 16 ms | 33108 KB | Output is correct |
33 | Correct | 383 ms | 49060 KB | Output is correct |
34 | Correct | 365 ms | 48996 KB | Output is correct |
35 | Correct | 449 ms | 55984 KB | Output is correct |
36 | Correct | 427 ms | 55988 KB | Output is correct |
37 | Correct | 384 ms | 47280 KB | Output is correct |
38 | Correct | 389 ms | 48204 KB | Output is correct |
39 | Correct | 355 ms | 47184 KB | Output is correct |
40 | Correct | 412 ms | 51092 KB | Output is correct |
41 | Correct | 337 ms | 47188 KB | Output is correct |
42 | Correct | 425 ms | 47200 KB | Output is correct |
43 | Correct | 405 ms | 51472 KB | Output is correct |
44 | Incorrect | 406 ms | 51428 KB | Output isn't correct |
45 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 33108 KB | Output is correct |
2 | Correct | 14 ms | 33108 KB | Output is correct |
3 | Correct | 16 ms | 33108 KB | Output is correct |
4 | Correct | 17 ms | 33108 KB | Output is correct |
5 | Correct | 14 ms | 33124 KB | Output is correct |
6 | Correct | 15 ms | 33064 KB | Output is correct |
7 | Correct | 13 ms | 33108 KB | Output is correct |
8 | Correct | 14 ms | 33140 KB | Output is correct |
9 | Correct | 14 ms | 33108 KB | Output is correct |
10 | Correct | 14 ms | 33108 KB | Output is correct |
11 | Correct | 17 ms | 33152 KB | Output is correct |
12 | Correct | 15 ms | 33108 KB | Output is correct |
13 | Correct | 14 ms | 33112 KB | Output is correct |
14 | Correct | 14 ms | 33052 KB | Output is correct |
15 | Correct | 17 ms | 33132 KB | Output is correct |
16 | Correct | 15 ms | 33092 KB | Output is correct |
17 | Correct | 18 ms | 33108 KB | Output is correct |
18 | Correct | 18 ms | 33108 KB | Output is correct |
19 | Correct | 16 ms | 33108 KB | Output is correct |
20 | Correct | 15 ms | 33148 KB | Output is correct |
21 | Correct | 15 ms | 33124 KB | Output is correct |
22 | Correct | 15 ms | 33052 KB | Output is correct |
23 | Correct | 15 ms | 33152 KB | Output is correct |
24 | Correct | 15 ms | 33188 KB | Output is correct |
25 | Correct | 16 ms | 33212 KB | Output is correct |
26 | Correct | 16 ms | 33188 KB | Output is correct |
27 | Correct | 16 ms | 33184 KB | Output is correct |
28 | Correct | 20 ms | 33172 KB | Output is correct |
29 | Correct | 16 ms | 33108 KB | Output is correct |
30 | Correct | 16 ms | 33168 KB | Output is correct |
31 | Correct | 15 ms | 33092 KB | Output is correct |
32 | Correct | 16 ms | 33108 KB | Output is correct |
33 | Correct | 453 ms | 49792 KB | Output is correct |
34 | Correct | 681 ms | 58660 KB | Output is correct |
35 | Correct | 606 ms | 49784 KB | Output is correct |
36 | Correct | 634 ms | 53676 KB | Output is correct |
37 | Correct | 431 ms | 49112 KB | Output is correct |
38 | Correct | 400 ms | 49024 KB | Output is correct |
39 | Correct | 481 ms | 55964 KB | Output is correct |
40 | Correct | 518 ms | 55980 KB | Output is correct |
41 | Correct | 386 ms | 47260 KB | Output is correct |
42 | Correct | 399 ms | 48172 KB | Output is correct |
43 | Correct | 364 ms | 47132 KB | Output is correct |
44 | Correct | 428 ms | 50996 KB | Output is correct |
45 | Correct | 369 ms | 47212 KB | Output is correct |
46 | Correct | 386 ms | 47268 KB | Output is correct |
47 | Correct | 424 ms | 51444 KB | Output is correct |
48 | Incorrect | 453 ms | 51432 KB | Output isn't correct |
49 | Halted | 0 ms | 0 KB | - |