답안 #793793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793793 2023-07-26T06:52:08 Z PixelCat 말 (IOI15_horses) C++14
17 / 100
213 ms 48148 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(L(id), l, m, L, R);
        if(R > m)  res *= qry(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);
    return solve();
}

int32_t updateY(int32_t pos, int32_t val) {
    y[pos] = val;
    uwu.upd(0, 0, n - 1, pos);
    return solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31572 KB Output is correct
2 Correct 11 ms 31572 KB Output is correct
3 Correct 12 ms 31632 KB Output is correct
4 Correct 12 ms 31596 KB Output is correct
5 Correct 12 ms 31616 KB Output is correct
6 Correct 12 ms 31572 KB Output is correct
7 Correct 12 ms 31572 KB Output is correct
8 Correct 12 ms 31544 KB Output is correct
9 Correct 12 ms 31628 KB Output is correct
10 Correct 13 ms 31592 KB Output is correct
11 Correct 12 ms 31532 KB Output is correct
12 Correct 12 ms 31616 KB Output is correct
13 Correct 13 ms 31536 KB Output is correct
14 Correct 12 ms 31612 KB Output is correct
15 Correct 12 ms 31560 KB Output is correct
16 Correct 16 ms 31532 KB Output is correct
17 Correct 12 ms 31572 KB Output is correct
18 Correct 12 ms 31568 KB Output is correct
19 Correct 12 ms 31516 KB Output is correct
20 Correct 14 ms 31516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31572 KB Output is correct
2 Correct 12 ms 31576 KB Output is correct
3 Correct 12 ms 31596 KB Output is correct
4 Correct 12 ms 31540 KB Output is correct
5 Correct 13 ms 31520 KB Output is correct
6 Correct 12 ms 31632 KB Output is correct
7 Correct 12 ms 31628 KB Output is correct
8 Correct 12 ms 31572 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 31596 KB Output is correct
13 Correct 12 ms 31572 KB Output is correct
14 Correct 12 ms 31572 KB Output is correct
15 Correct 12 ms 31628 KB Output is correct
16 Correct 15 ms 31556 KB Output is correct
17 Correct 13 ms 31524 KB Output is correct
18 Correct 12 ms 31572 KB Output is correct
19 Correct 12 ms 31592 KB Output is correct
20 Correct 12 ms 31552 KB Output is correct
21 Incorrect 12 ms 31572 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 213 ms 48148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31572 KB Output is correct
2 Correct 13 ms 31572 KB Output is correct
3 Correct 13 ms 31600 KB Output is correct
4 Correct 12 ms 31540 KB Output is correct
5 Correct 13 ms 31572 KB Output is correct
6 Correct 13 ms 31536 KB Output is correct
7 Correct 14 ms 31624 KB Output is correct
8 Correct 12 ms 31632 KB Output is correct
9 Correct 12 ms 31528 KB Output is correct
10 Correct 13 ms 31540 KB Output is correct
11 Correct 13 ms 31572 KB Output is correct
12 Correct 15 ms 31560 KB Output is correct
13 Correct 12 ms 31596 KB Output is correct
14 Correct 15 ms 31608 KB Output is correct
15 Correct 13 ms 31512 KB Output is correct
16 Correct 13 ms 31572 KB Output is correct
17 Correct 15 ms 31572 KB Output is correct
18 Correct 15 ms 31572 KB Output is correct
19 Correct 13 ms 31564 KB Output is correct
20 Correct 14 ms 31700 KB Output is correct
21 Incorrect 13 ms 31572 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31572 KB Output is correct
2 Correct 12 ms 31644 KB Output is correct
3 Correct 12 ms 31572 KB Output is correct
4 Correct 14 ms 31624 KB Output is correct
5 Correct 12 ms 31592 KB Output is correct
6 Correct 14 ms 31576 KB Output is correct
7 Correct 12 ms 31552 KB Output is correct
8 Correct 14 ms 31636 KB Output is correct
9 Correct 12 ms 31640 KB Output is correct
10 Correct 15 ms 31520 KB Output is correct
11 Correct 13 ms 31564 KB Output is correct
12 Correct 15 ms 31524 KB Output is correct
13 Correct 13 ms 31572 KB Output is correct
14 Correct 13 ms 31572 KB Output is correct
15 Correct 12 ms 31532 KB Output is correct
16 Correct 13 ms 31620 KB Output is correct
17 Correct 12 ms 31632 KB Output is correct
18 Correct 12 ms 31572 KB Output is correct
19 Correct 12 ms 31560 KB Output is correct
20 Correct 12 ms 31572 KB Output is correct
21 Incorrect 12 ms 31612 KB Output isn't correct
22 Halted 0 ms 0 KB -