Submission #819778

# Submission time Handle Problem Language Result Execution time Memory
819778 2023-08-10T13:24:47 Z josanneo22 Horses (IOI15_horses) C++17
100 / 100
301 ms 91288 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const ll N = 5e5 + 500, mod = 1e9 + 7;
ll chen(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }
ll jia(ll x, ll y) { return ((x % mod) + (y % mod)) % mod; }
ll a[N], b[N];
struct yl {
    ll l, r, pro, ans;
    ld sumlog, mx;
}tr[N << 2];
void pushup(ll p) {
    ll l = p << 1, r = p << 1 | 1;
    tr[p].sumlog = tr[l].sumlog + tr[r].sumlog;
    tr[p].pro = chen(tr[l].pro, tr[r].pro);
    if (tr[l].mx < tr[l].sumlog + tr[r].mx) {
        tr[p].mx = tr[l].sumlog + tr[r].mx;
        tr[p].ans = chen(tr[l].pro, tr[r].ans);
    }
    else {
        tr[p].mx = tr[l].mx;
        tr[p].ans = tr[l].ans;
    }
    return;
}
void build(ll p, ll l, ll r) {
    tr[p].l = l; tr[p].r = r;
    if (l == r) {
        tr[p].ans = chen(a[l], b[l]);
        tr[p].pro = a[l] % mod;
        tr[p].sumlog = log(a[l]);
        tr[p].mx = log(a[l] * b[l]);
        return;
    }
    ll mid = (l + r) >> 1;
    build(p << 1, l, mid); build(p << 1 | 1, mid + 1, r);
    pushup(p);
    return;
}
void modify(ll p, ll l) {
    if (tr[p].l == tr[p].r) {
        tr[p].ans = chen(a[l], b[l]);
        tr[p].pro = a[l] % mod;
        tr[p].sumlog = log(a[l]);
        tr[p].mx = log(a[l] * b[l]);
        return;
    }
    ll mid = (tr[p].l + tr[p].r) >> 1;
    if (l <= mid) modify(p << 1, l);
    if (l > mid) modify(p << 1 | 1, l);
    pushup(p);
    return;
}

int init(int n, int X[], int Y[]) {
    for (int i = 1; i <= n; i++) a[i] = X[i - 1];
    for (int i = 1; i <= n; i++) b[i] = Y[i - 1];
    build(1, 1, n);
    return (int)tr[1].ans;
}
int updateX(int pos, int val) {
    pos++;
    a[pos] = (ll)val; modify(1, pos);
    return (int)tr[1].ans;
}
int updateY(int pos, int val) {
    pos++;
    b[pos] = (ll)val; modify(1, pos);
    return (int)tr[1].ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 216 KB Output is correct
11 Correct 1 ms 220 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 216 KB Output is correct
14 Correct 1 ms 220 KB Output is correct
15 Correct 0 ms 220 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 216 KB Output is correct
18 Correct 1 ms 216 KB Output is correct
19 Correct 1 ms 216 KB Output is correct
20 Correct 1 ms 220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 220 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 216 KB Output is correct
19 Correct 1 ms 216 KB Output is correct
20 Correct 1 ms 216 KB Output is correct
21 Correct 1 ms 216 KB Output is correct
22 Correct 1 ms 216 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 476 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 448 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 452 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 115 ms 82464 KB Output is correct
2 Correct 291 ms 91288 KB Output is correct
3 Correct 212 ms 82456 KB Output is correct
4 Correct 301 ms 86328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 412 KB Output is correct
29 Correct 1 ms 488 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 77 ms 81748 KB Output is correct
34 Correct 93 ms 81636 KB Output is correct
35 Correct 95 ms 88656 KB Output is correct
36 Correct 111 ms 88536 KB Output is correct
37 Correct 84 ms 79920 KB Output is correct
38 Correct 68 ms 80716 KB Output is correct
39 Correct 52 ms 79760 KB Output is correct
40 Correct 75 ms 83816 KB Output is correct
41 Correct 60 ms 79760 KB Output is correct
42 Correct 64 ms 79880 KB Output is correct
43 Correct 76 ms 84104 KB Output is correct
44 Correct 75 ms 84052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 1 ms 472 KB Output is correct
27 Correct 1 ms 432 KB Output is correct
28 Correct 1 ms 448 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 464 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 448 KB Output is correct
33 Correct 114 ms 82440 KB Output is correct
34 Correct 250 ms 91288 KB Output is correct
35 Correct 192 ms 82504 KB Output is correct
36 Correct 192 ms 86272 KB Output is correct
37 Correct 77 ms 81656 KB Output is correct
38 Correct 84 ms 81676 KB Output is correct
39 Correct 115 ms 88696 KB Output is correct
40 Correct 103 ms 88644 KB Output is correct
41 Correct 66 ms 79876 KB Output is correct
42 Correct 63 ms 80752 KB Output is correct
43 Correct 58 ms 79788 KB Output is correct
44 Correct 76 ms 83696 KB Output is correct
45 Correct 52 ms 79824 KB Output is correct
46 Correct 62 ms 79876 KB Output is correct
47 Correct 71 ms 84096 KB Output is correct
48 Correct 87 ms 84080 KB Output is correct
49 Correct 197 ms 83708 KB Output is correct
50 Correct 184 ms 83740 KB Output is correct
51 Correct 137 ms 90464 KB Output is correct
52 Correct 146 ms 90052 KB Output is correct
53 Correct 182 ms 82172 KB Output is correct
54 Correct 128 ms 82636 KB Output is correct
55 Correct 97 ms 80788 KB Output is correct
56 Correct 124 ms 85536 KB Output is correct
57 Correct 126 ms 81488 KB Output is correct
58 Correct 95 ms 81996 KB Output is correct
59 Correct 82 ms 84048 KB Output is correct