# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
396806 | 2021-04-30T18:56:30 Z | rainboy | Horses (IOI15_horses) | C | 152 ms | 30916 KB |
#include "horses.h" #include <string.h> #define N 500000 #define N_ (1 << 19) /* N_ = pow2(ceil(log2(N))) */ #define MD 1000000007 #define INF 0x3f3f3f3f long long min(long long a, long long b) { return a < b ? a : b; } int xx[N], yy[N], pp[N_ * 2], qq[N_ * 2], suf_[N_ * 2], prod[N_ * 2], prod_[N_ * 2], n_; void pul(int i) { int l = i << 1, r = l | 1; prod[i] = min((long long) prod[l] * prod[r], INF); prod_[i] = (long long) prod_[l] * prod_[r] % MD; if (pp[r] == 0 || ((long long) pp[l] * qq[r]) / ((long long) qq[l] * pp[r]) >= prod[r]) pp[i] = pp[l], qq[i] = qq[l] * prod[r], suf_[i] = suf_[l]; else pp[i] = pp[r], qq[i] = qq[r], suf_[i] = (long long) prod_[l] * suf_[r] % MD; } int init(int n, int *xx_, int *yy_) { int i; memcpy(xx, xx_, n * sizeof *xx_), memcpy(yy, yy_, n * sizeof *yy_); n_ = 1; while (n_ < n) n_ <<= 1; for (i = 0; i < n_; i++) { prod[n_ + i] = prod_[n_ + i] = i < n ? xx[i] : 1; pp[n_ + i] = i < n ? yy[i] : 0, qq[n_ + i] = 1, suf_[n_ + i] = (long long) xx[i] * (i < n ? yy[i] : 0) % MD; } for (i = n_ - 1; i > 0; i--) pul(i); return suf_[1]; } int updateX(int i, int x) { xx[i] = x; prod[n_ + i] = prod_[n_ + i] = xx[i], suf_[n_ + i] = (long long) xx[i] * yy[i] % MD; i += n_; while (i > 1) pul(i >>= 1); return suf_[1]; } int updateY(int i, int y) { yy[i] = y; pp[n_ + i] = yy[i], qq[n_ + i] = 1, suf_[n_ + i] = (long long) xx[i] * yy[i] % MD; i += n_; while (i > 1) pul(i >>= 1); return suf_[1]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 2 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 2 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 412 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 2 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 75 ms | 29668 KB | Output is correct |
2 | Correct | 152 ms | 30880 KB | Output is correct |
3 | Correct | 115 ms | 30780 KB | Output is correct |
4 | Correct | 131 ms | 30860 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 292 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 55 ms | 29764 KB | Output is correct |
34 | Correct | 47 ms | 29892 KB | Output is correct |
35 | Correct | 66 ms | 29968 KB | Output is correct |
36 | Correct | 75 ms | 29960 KB | Output is correct |
37 | Correct | 37 ms | 29976 KB | Output is correct |
38 | Correct | 38 ms | 29892 KB | Output is correct |
39 | Correct | 38 ms | 29812 KB | Output is correct |
40 | Correct | 49 ms | 29932 KB | Output is correct |
41 | Correct | 35 ms | 29892 KB | Output is correct |
42 | Correct | 31 ms | 30004 KB | Output is correct |
43 | Correct | 46 ms | 29908 KB | Output is correct |
44 | Correct | 47 ms | 29908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 204 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 320 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 74 ms | 30788 KB | Output is correct |
34 | Correct | 145 ms | 30788 KB | Output is correct |
35 | Correct | 112 ms | 30888 KB | Output is correct |
36 | Correct | 140 ms | 30848 KB | Output is correct |
37 | Correct | 47 ms | 29900 KB | Output is correct |
38 | Correct | 47 ms | 29892 KB | Output is correct |
39 | Correct | 68 ms | 29904 KB | Output is correct |
40 | Correct | 69 ms | 29920 KB | Output is correct |
41 | Correct | 36 ms | 29912 KB | Output is correct |
42 | Correct | 37 ms | 29880 KB | Output is correct |
43 | Correct | 32 ms | 29888 KB | Output is correct |
44 | Correct | 48 ms | 29912 KB | Output is correct |
45 | Correct | 34 ms | 29936 KB | Output is correct |
46 | Correct | 32 ms | 29976 KB | Output is correct |
47 | Correct | 46 ms | 29892 KB | Output is correct |
48 | Correct | 52 ms | 29836 KB | Output is correct |
49 | Correct | 131 ms | 30816 KB | Output is correct |
50 | Correct | 122 ms | 30836 KB | Output is correct |
51 | Correct | 105 ms | 30888 KB | Output is correct |
52 | Correct | 128 ms | 30820 KB | Output is correct |
53 | Correct | 110 ms | 30840 KB | Output is correct |
54 | Correct | 81 ms | 30728 KB | Output is correct |
55 | Correct | 95 ms | 30016 KB | Output is correct |
56 | Correct | 92 ms | 30844 KB | Output is correct |
57 | Correct | 91 ms | 30804 KB | Output is correct |
58 | Correct | 74 ms | 30916 KB | Output is correct |
59 | Correct | 47 ms | 29904 KB | Output is correct |