Submission #793814

# Submission time Handle Problem Language Result Execution time Memory
793814 2023-07-26T06:59:48 Z PixelCat Horses (IOI15_horses) C++14
34 / 100
220 ms 48244 KB
#ifdef NYAOWO
#include "grader.cpp"
#endif

#include "horses.h"

#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define int LL
using namespace std;
using LL = long long;
using pii = pair<int, int>;

const int MAXN = 500'000;
const int MOD = 1'000'000'007;
const int INF = 2'000'000'000;

#define L(id) ((id) * 2 + 1)
#define R(id) ((id) * 2 + 2)
struct SegTree {
    int a[MAXN * 4 + 10];
    int b[MAXN * 4 + 10];
    void build() {
        fill(a, a + sizeof(a) / sizeof(int), 1);
        fill(b, b + sizeof(b) / sizeof(int), 1);
    }
    void upd(int id, int l, int r, int i, int x) {
        if(l == r) {
            a[id] = x;
            b[id] = x;
            return;
        }
        int m = (l + r) / 2;
        if(i <= m) upd(L(id), l, m, i, x);
        else       upd(R(id), m + 1, r, i, x);
        a[id] = min(INF, a[L(id)] * a[R(id)]);
        b[id] = b[L(id)] * b[R(id)] % MOD;
    }
    int qry(int id, int l, int r, int L, int R) {
        if(l >= L && r <= R) return a[id];
        int m = (l + r) / 2;
        int res = 1;
        if(L <= m) res = min(INF, res * qry(L(id), l, m, L, R));
        if(R > m)  res = min(INF, res * qry(R(id), m + 1, r, L, R));
        return res;
    }
    int qry_mod(int id, int l, int r, int L, int R) {
        if(l >= L && r <= R) return b[id];
        int m = (l + r) / 2;
        int res = 1;
        if(L <= m) res *= qry_mod(L(id), l, m, L, R);
        if(R > m)  res *= qry_mod(R(id), m + 1, r, L, R);
        return res % MOD;
    }
} seg;

int n;
int x[MAXN + 10];
int y[MAXN + 10];

struct SegTree2 {
    bool smol(const int &a, const int &b) {
        if(a == b) return false;
        if(a > b) return !smol(b, a);
        return y[a] < seg.qry(0, 0, n - 1, a + 1, b) * y[b];
    }
    int zzzz(const int &a, const int &b) {
        if(smol(a, b)) return b;
        return a;
    }
    int mx[MAXN + 10];
    void build(int id, int l, int r) {
        if(l == r) {
            mx[id] = l;
            return;
        }
        int m = (l + r) / 2;
        build(L(id), l, m);
        build(R(id), m + 1, r);
        mx[id] = zzzz(mx[L(id)], mx[R(id)]);
    }
    void upd(int id, int l, int r, int i) {
        if(l == r) return;
        int m = (l + r) / 2;
        if(i <= m) upd(L(id), l, m, i);
        else       upd(R(id), m + 1, r, i);
        mx[id] = zzzz(mx[L(id)], mx[R(id)]);
    }
} uwu;

int32_t eval(int pos) {
    return (int32_t)(y[pos] * seg.qry_mod(0, 0, n - 1, 0, pos) % MOD);
}
int32_t solve() {
    int pos = uwu.mx[0];
    return eval(pos);
}

int32_t init(int32_t N, int32_t X[], int32_t Y[]) {
    n = N;
    seg.build();
    For(i, 0, n - 1) {
        x[i] = X[i];
        seg.upd(0, 0, n - 1, i, x[i]);
    }
    For(i, 0, n - 1) {
        y[i] = Y[i];
    }
    uwu.build(0, 0, n - 1);
    return solve();
}

int32_t updateX(int32_t pos, int32_t val) {	
    x[pos] = val;
    seg.upd(0, 0, n - 1, pos, val);
    uwu.upd(0, 0, n - 1, pos);
    // uwu.build(0, 0, n - 1);
    return solve();
}

int32_t updateY(int32_t pos, int32_t val) {
    y[pos] = val;
    uwu.upd(0, 0, n - 1, pos);
    // uwu.build(0, 0, n - 1);
    return solve();
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 31572 KB Output is correct
2 Correct 11 ms 31524 KB Output is correct
3 Correct 12 ms 31548 KB Output is correct
4 Correct 12 ms 31572 KB Output is correct
5 Correct 11 ms 31568 KB Output is correct
6 Correct 11 ms 31572 KB Output is correct
7 Correct 12 ms 31564 KB Output is correct
8 Correct 12 ms 31548 KB Output is correct
9 Correct 12 ms 31572 KB Output is correct
10 Correct 12 ms 31572 KB Output is correct
11 Correct 12 ms 31572 KB Output is correct
12 Correct 12 ms 31572 KB Output is correct
13 Correct 12 ms 31572 KB Output is correct
14 Correct 12 ms 31608 KB Output is correct
15 Correct 12 ms 31588 KB Output is correct
16 Correct 12 ms 31572 KB Output is correct
17 Correct 12 ms 31572 KB Output is correct
18 Correct 12 ms 31548 KB Output is correct
19 Correct 11 ms 31572 KB Output is correct
20 Correct 12 ms 31572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 31572 KB Output is correct
2 Correct 11 ms 31532 KB Output is correct
3 Correct 11 ms 31556 KB Output is correct
4 Correct 12 ms 31568 KB Output is correct
5 Correct 12 ms 31576 KB Output is correct
6 Correct 12 ms 31572 KB Output is correct
7 Correct 12 ms 31636 KB Output is correct
8 Correct 12 ms 31572 KB Output is correct
9 Correct 13 ms 31572 KB Output is correct
10 Correct 12 ms 31572 KB Output is correct
11 Correct 12 ms 31572 KB Output is correct
12 Correct 12 ms 31572 KB Output is correct
13 Correct 12 ms 31572 KB Output is correct
14 Correct 12 ms 31584 KB Output is correct
15 Correct 12 ms 31592 KB Output is correct
16 Correct 14 ms 31536 KB Output is correct
17 Correct 12 ms 31572 KB Output is correct
18 Correct 12 ms 31572 KB Output is correct
19 Correct 12 ms 31552 KB Output is correct
20 Correct 13 ms 31528 KB Output is correct
21 Correct 13 ms 31572 KB Output is correct
22 Correct 12 ms 31572 KB Output is correct
23 Correct 13 ms 31660 KB Output is correct
24 Correct 13 ms 31600 KB Output is correct
25 Correct 13 ms 31600 KB Output is correct
26 Correct 12 ms 31572 KB Output is correct
27 Correct 13 ms 31640 KB Output is correct
28 Correct 13 ms 31656 KB Output is correct
29 Correct 13 ms 31572 KB Output is correct
30 Correct 13 ms 31680 KB Output is correct
31 Correct 13 ms 31572 KB Output is correct
32 Correct 13 ms 31684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 219 ms 48244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 31632 KB Output is correct
2 Correct 13 ms 31572 KB Output is correct
3 Correct 12 ms 31552 KB Output is correct
4 Correct 13 ms 31576 KB Output is correct
5 Correct 12 ms 31572 KB Output is correct
6 Correct 12 ms 31560 KB Output is correct
7 Correct 13 ms 31572 KB Output is correct
8 Correct 15 ms 31572 KB Output is correct
9 Correct 11 ms 31572 KB Output is correct
10 Correct 12 ms 31572 KB Output is correct
11 Correct 12 ms 31620 KB Output is correct
12 Correct 12 ms 31572 KB Output is correct
13 Correct 12 ms 31572 KB Output is correct
14 Correct 11 ms 31632 KB Output is correct
15 Correct 10 ms 31568 KB Output is correct
16 Correct 11 ms 31568 KB Output is correct
17 Correct 11 ms 31596 KB Output is correct
18 Correct 10 ms 31572 KB Output is correct
19 Correct 14 ms 31572 KB Output is correct
20 Correct 12 ms 31636 KB Output is correct
21 Correct 11 ms 31572 KB Output is correct
22 Correct 15 ms 31572 KB Output is correct
23 Correct 16 ms 31572 KB Output is correct
24 Correct 12 ms 31576 KB Output is correct
25 Correct 12 ms 31676 KB Output is correct
26 Correct 13 ms 31572 KB Output is correct
27 Correct 12 ms 31572 KB Output is correct
28 Correct 14 ms 31576 KB Output is correct
29 Correct 13 ms 31660 KB Output is correct
30 Correct 16 ms 31608 KB Output is correct
31 Correct 12 ms 31572 KB Output is correct
32 Correct 11 ms 31572 KB Output is correct
33 Incorrect 164 ms 47332 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 31572 KB Output is correct
2 Correct 12 ms 31572 KB Output is correct
3 Correct 11 ms 31584 KB Output is correct
4 Correct 12 ms 31572 KB Output is correct
5 Correct 13 ms 31548 KB Output is correct
6 Correct 14 ms 31572 KB Output is correct
7 Correct 16 ms 31572 KB Output is correct
8 Correct 12 ms 31572 KB Output is correct
9 Correct 11 ms 31572 KB Output is correct
10 Correct 11 ms 31576 KB Output is correct
11 Correct 11 ms 31572 KB Output is correct
12 Correct 11 ms 31572 KB Output is correct
13 Correct 11 ms 31600 KB Output is correct
14 Correct 12 ms 31572 KB Output is correct
15 Correct 11 ms 31572 KB Output is correct
16 Correct 13 ms 31572 KB Output is correct
17 Correct 11 ms 31572 KB Output is correct
18 Correct 11 ms 31572 KB Output is correct
19 Correct 11 ms 31572 KB Output is correct
20 Correct 11 ms 31572 KB Output is correct
21 Correct 14 ms 31520 KB Output is correct
22 Correct 15 ms 31568 KB Output is correct
23 Correct 15 ms 31572 KB Output is correct
24 Correct 14 ms 31572 KB Output is correct
25 Correct 16 ms 31572 KB Output is correct
26 Correct 12 ms 31572 KB Output is correct
27 Correct 13 ms 31572 KB Output is correct
28 Correct 12 ms 31564 KB Output is correct
29 Correct 13 ms 31628 KB Output is correct
30 Correct 14 ms 31572 KB Output is correct
31 Correct 13 ms 31572 KB Output is correct
32 Correct 13 ms 31676 KB Output is correct
33 Incorrect 220 ms 48168 KB Output isn't correct
34 Halted 0 ms 0 KB -