# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
996424 | 2024-06-10T14:59:12 Z | phoenix | 말 (IOI15_horses) | C++17 | 227 ms | 41556 KB |
#include<bits/stdc++.h> // #include "horses.h" using namespace std; using ll = long long; const int MOD = 1e9 + 7; const int N = (1 << 19); int n; ll y[N]; int mx[2 * N]; struct Z { bool over = 0; ll x = 1; }; Z t[2 * N]; void updX(int pos, int val) { for(t[pos += N].x = val; pos > 1; pos >>= 1) { t[pos >> 1].over = (t[pos].over | t[(pos ^ 1)].over | (t[pos].x * t[(pos ^ 1)].x >= MOD)); t[pos >> 1].x = (t[pos].x * t[(pos ^ 1)].x) % MOD; } } Z get(int ql, int qr) { Z res; for(ql += N, qr += N + 1; ql < qr; ql >>= 1, qr >>= 1) { if(ql & 1) { res.over = (res.over | t[ql].over | (res.x * t[ql].x >= MOD)); res.x = (res.x * t[ql].x) % MOD; ql++; } if(qr & 1) { qr--; res.over = (res.over | t[qr].over | (res.x * t[qr].x >= MOD)); res.x = (res.x * t[qr].x) % MOD; } } return res; } void build(int l = 0, int r = N - 1, int v = 1) { if(l == r) { mx[v] = l; return; } int m = (l + r) / 2; build(l, m, 2 * v); build(m + 1, r, 2 * v + 1); Z x = get(mx[2 * v] + 1, mx[2 * v + 1]); mx[v] = mx[2 * v + (x.over || x.x * y[mx[2 * v + 1]] >= y[mx[2 * v]])]; } void update(int pos) { for(pos += N, pos >>= 1; pos; pos >>= 1) { Z x = get(mx[2 * pos] + 1, mx[2 * pos + 1]); mx[pos] = mx[2 * pos + (x.over || x.x * y[mx[2 * pos + 1]] >= y[mx[2 * pos]])]; } } int init(int N, int X[], int Y[]) { n = N; for(int i = 0; i < n; i++) { y[i] = Y[i]; updX(i, X[i]); } build(); return (y[mx[1]] * get(0, mx[1]).x) % MOD; } int updateX(int pos, int val) { updX(pos, val); update(pos); return (y[mx[1]] * get(0, mx[1]).x) % MOD; } int updateY(int pos, int val) { y[pos] = val; update(pos); return (y[mx[1]] * get(0, mx[1]).x) % MOD; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4700 KB | Output is correct |
2 | Correct | 7 ms | 4700 KB | Output is correct |
3 | Correct | 7 ms | 4700 KB | Output is correct |
4 | Correct | 7 ms | 4700 KB | Output is correct |
5 | Correct | 7 ms | 4700 KB | Output is correct |
6 | Correct | 8 ms | 4696 KB | Output is correct |
7 | Correct | 11 ms | 4700 KB | Output is correct |
8 | Correct | 8 ms | 4696 KB | Output is correct |
9 | Correct | 7 ms | 4700 KB | Output is correct |
10 | Correct | 7 ms | 4696 KB | Output is correct |
11 | Correct | 7 ms | 4796 KB | Output is correct |
12 | Correct | 8 ms | 4700 KB | Output is correct |
13 | Correct | 8 ms | 4700 KB | Output is correct |
14 | Correct | 12 ms | 4804 KB | Output is correct |
15 | Correct | 8 ms | 4700 KB | Output is correct |
16 | Correct | 8 ms | 4696 KB | Output is correct |
17 | Correct | 8 ms | 4696 KB | Output is correct |
18 | Correct | 7 ms | 4700 KB | Output is correct |
19 | Correct | 8 ms | 4696 KB | Output is correct |
20 | Correct | 7 ms | 4700 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4700 KB | Output is correct |
2 | Correct | 7 ms | 4700 KB | Output is correct |
3 | Correct | 7 ms | 4700 KB | Output is correct |
4 | Correct | 9 ms | 4696 KB | Output is correct |
5 | Correct | 7 ms | 4696 KB | Output is correct |
6 | Correct | 7 ms | 4700 KB | Output is correct |
7 | Correct | 9 ms | 4700 KB | Output is correct |
8 | Correct | 8 ms | 4696 KB | Output is correct |
9 | Correct | 9 ms | 4696 KB | Output is correct |
10 | Correct | 8 ms | 4696 KB | Output is correct |
11 | Correct | 8 ms | 4696 KB | Output is correct |
12 | Correct | 7 ms | 4700 KB | Output is correct |
13 | Correct | 7 ms | 4708 KB | Output is correct |
14 | Correct | 7 ms | 4696 KB | Output is correct |
15 | Correct | 8 ms | 4700 KB | Output is correct |
16 | Correct | 11 ms | 4700 KB | Output is correct |
17 | Correct | 7 ms | 4696 KB | Output is correct |
18 | Correct | 7 ms | 4700 KB | Output is correct |
19 | Correct | 7 ms | 4776 KB | Output is correct |
20 | Correct | 8 ms | 4700 KB | Output is correct |
21 | Correct | 8 ms | 4700 KB | Output is correct |
22 | Correct | 7 ms | 4696 KB | Output is correct |
23 | Correct | 9 ms | 4696 KB | Output is correct |
24 | Correct | 10 ms | 4700 KB | Output is correct |
25 | Correct | 9 ms | 4876 KB | Output is correct |
26 | Correct | 8 ms | 4700 KB | Output is correct |
27 | Correct | 8 ms | 4696 KB | Output is correct |
28 | Correct | 8 ms | 4700 KB | Output is correct |
29 | Correct | 8 ms | 4700 KB | Output is correct |
30 | Correct | 9 ms | 4700 KB | Output is correct |
31 | Correct | 8 ms | 4696 KB | Output is correct |
32 | Correct | 8 ms | 4700 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 139 ms | 32748 KB | Output is correct |
2 | Correct | 163 ms | 41552 KB | Output is correct |
3 | Correct | 163 ms | 32596 KB | Output is correct |
4 | Correct | 182 ms | 36432 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 4700 KB | Output is correct |
2 | Correct | 8 ms | 4700 KB | Output is correct |
3 | Correct | 8 ms | 4700 KB | Output is correct |
4 | Correct | 8 ms | 4700 KB | Output is correct |
5 | Correct | 8 ms | 4700 KB | Output is correct |
6 | Correct | 8 ms | 4772 KB | Output is correct |
7 | Correct | 8 ms | 4696 KB | Output is correct |
8 | Correct | 8 ms | 4700 KB | Output is correct |
9 | Correct | 9 ms | 4700 KB | Output is correct |
10 | Correct | 10 ms | 4700 KB | Output is correct |
11 | Correct | 8 ms | 4700 KB | Output is correct |
12 | Correct | 7 ms | 4696 KB | Output is correct |
13 | Correct | 7 ms | 4696 KB | Output is correct |
14 | Correct | 7 ms | 4700 KB | Output is correct |
15 | Correct | 8 ms | 4696 KB | Output is correct |
16 | Correct | 7 ms | 4696 KB | Output is correct |
17 | Correct | 9 ms | 4700 KB | Output is correct |
18 | Correct | 10 ms | 4700 KB | Output is correct |
19 | Correct | 7 ms | 4700 KB | Output is correct |
20 | Correct | 8 ms | 4700 KB | Output is correct |
21 | Correct | 8 ms | 4696 KB | Output is correct |
22 | Correct | 8 ms | 4700 KB | Output is correct |
23 | Correct | 9 ms | 4696 KB | Output is correct |
24 | Correct | 8 ms | 4700 KB | Output is correct |
25 | Correct | 8 ms | 4700 KB | Output is correct |
26 | Correct | 8 ms | 4700 KB | Output is correct |
27 | Correct | 9 ms | 4700 KB | Output is correct |
28 | Correct | 9 ms | 4684 KB | Output is correct |
29 | Correct | 8 ms | 4700 KB | Output is correct |
30 | Correct | 9 ms | 4700 KB | Output is correct |
31 | Correct | 9 ms | 4700 KB | Output is correct |
32 | Correct | 9 ms | 4700 KB | Output is correct |
33 | Correct | 88 ms | 31904 KB | Output is correct |
34 | Correct | 91 ms | 32080 KB | Output is correct |
35 | Correct | 95 ms | 38992 KB | Output is correct |
36 | Correct | 97 ms | 39264 KB | Output is correct |
37 | Correct | 75 ms | 30032 KB | Output is correct |
38 | Correct | 74 ms | 30968 KB | Output is correct |
39 | Correct | 68 ms | 30032 KB | Output is correct |
40 | Correct | 80 ms | 33904 KB | Output is correct |
41 | Correct | 68 ms | 30032 KB | Output is correct |
42 | Correct | 68 ms | 30036 KB | Output is correct |
43 | Correct | 76 ms | 34196 KB | Output is correct |
44 | Correct | 76 ms | 34384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4700 KB | Output is correct |
2 | Correct | 7 ms | 4700 KB | Output is correct |
3 | Correct | 7 ms | 4700 KB | Output is correct |
4 | Correct | 7 ms | 4700 KB | Output is correct |
5 | Correct | 8 ms | 4672 KB | Output is correct |
6 | Correct | 7 ms | 4700 KB | Output is correct |
7 | Correct | 7 ms | 4756 KB | Output is correct |
8 | Correct | 7 ms | 4696 KB | Output is correct |
9 | Correct | 7 ms | 4700 KB | Output is correct |
10 | Correct | 8 ms | 4696 KB | Output is correct |
11 | Correct | 11 ms | 4700 KB | Output is correct |
12 | Correct | 7 ms | 4700 KB | Output is correct |
13 | Correct | 7 ms | 4700 KB | Output is correct |
14 | Correct | 7 ms | 4780 KB | Output is correct |
15 | Correct | 7 ms | 4696 KB | Output is correct |
16 | Correct | 8 ms | 4956 KB | Output is correct |
17 | Correct | 7 ms | 4700 KB | Output is correct |
18 | Correct | 8 ms | 4696 KB | Output is correct |
19 | Correct | 8 ms | 4700 KB | Output is correct |
20 | Correct | 9 ms | 4696 KB | Output is correct |
21 | Correct | 8 ms | 4696 KB | Output is correct |
22 | Correct | 7 ms | 4700 KB | Output is correct |
23 | Correct | 11 ms | 4700 KB | Output is correct |
24 | Correct | 9 ms | 4700 KB | Output is correct |
25 | Correct | 10 ms | 4700 KB | Output is correct |
26 | Correct | 8 ms | 4696 KB | Output is correct |
27 | Correct | 8 ms | 4700 KB | Output is correct |
28 | Correct | 9 ms | 4700 KB | Output is correct |
29 | Correct | 9 ms | 4700 KB | Output is correct |
30 | Correct | 9 ms | 4696 KB | Output is correct |
31 | Correct | 8 ms | 4700 KB | Output is correct |
32 | Correct | 10 ms | 4700 KB | Output is correct |
33 | Correct | 137 ms | 32792 KB | Output is correct |
34 | Correct | 164 ms | 41556 KB | Output is correct |
35 | Correct | 153 ms | 32592 KB | Output is correct |
36 | Correct | 170 ms | 36688 KB | Output is correct |
37 | Correct | 91 ms | 31928 KB | Output is correct |
38 | Correct | 95 ms | 32052 KB | Output is correct |
39 | Correct | 96 ms | 38976 KB | Output is correct |
40 | Correct | 98 ms | 38876 KB | Output is correct |
41 | Correct | 70 ms | 30036 KB | Output is correct |
42 | Correct | 70 ms | 31064 KB | Output is correct |
43 | Correct | 63 ms | 30032 KB | Output is correct |
44 | Correct | 77 ms | 33876 KB | Output is correct |
45 | Correct | 75 ms | 30036 KB | Output is correct |
46 | Correct | 66 ms | 30128 KB | Output is correct |
47 | Correct | 79 ms | 34224 KB | Output is correct |
48 | Correct | 73 ms | 34384 KB | Output is correct |
49 | Correct | 213 ms | 33876 KB | Output is correct |
50 | Correct | 227 ms | 33872 KB | Output is correct |
51 | Correct | 163 ms | 40784 KB | Output is correct |
52 | Correct | 154 ms | 40348 KB | Output is correct |
53 | Correct | 155 ms | 32340 KB | Output is correct |
54 | Correct | 127 ms | 32848 KB | Output is correct |
55 | Correct | 114 ms | 31212 KB | Output is correct |
56 | Correct | 135 ms | 35668 KB | Output is correct |
57 | Correct | 150 ms | 31824 KB | Output is correct |
58 | Correct | 146 ms | 32084 KB | Output is correct |
59 | Correct | 77 ms | 34388 KB | Output is correct |