답안 #730333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
730333 2023-04-25T17:38:51 Z t6twotwo 자동 인형 (IOI18_doll) C++17
컴파일 오류
0 ms 0 KB
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1E18;
vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
    int N = H.size();
    int Q = L.size();
    if (N <= 5000 && Q <= 5000) {
        vector pfs(N, vector<ll>(N + 1));
        for (int i = 0; i < N; i++) {
            vector<int> mx(N);
            mx[i] = H[i];
            for (int j = i - 1; j >= 0; j--) {
                mx[j] = max(mx[j + 1], H[j]);
            }
            for (int j = i + 1; j < N; j++) {
                mx[j] = max(mx[j - 1], H[j]);
            }
            for (int j = 0; j < N; j++) {
                pfs[i][j + 1] = pfs[i][j] + mx[j];
            }
        }
        vector<ll> ans(Q, inf);
        for (int i = 0; i < Q; i++) {
            for (int j = L[i]; j <= R[i]; j++) {
                ans[i] = min(ans[i], pfs[j][R[i] + 1] - pfs[j][L[i]]);
            }
        }
        return ans;
    } else {
        vector<int> LG(N, N);
        for (int i = 0; i < N; i++) {
            if (H[i] == 1) {
                LG[i] = min(i == 0 ? N : LG[i - 1], i);
            }
        }
        vector<int> RG(N, -1);
        for (int i = N - 1; i >= 0; i--) {
            if (H[i] == 1) {
                RG[i] = max(i == N - 1 ? -1 : RG[i + 1], i);
            }
        }
        vector<int> S(N);
        for (int i = 0; i < N; i++) {
            S[i] = 2 * N - RG[i] + LG[i] - 1;
        }
        vector<int> one(N + 1);
        for (int i = 0; i < N; i++) {
            one[i + 1] = one[i] + (H[i] == 1);
        }
        int lg = __lg(N);
        vector ST(N, vector<int>(lg + 1));
        for (int i = 0; i < N; i++) {
            ST[i][0] = S[i];
        }
        for (int j = 0; j < lg; j++) {
            for (int i = 0; i + (2 << j) <= N; i++) {
                ST[i][j + 1] = min(ST[i][j], ST[i + (1 << j)][j]);
            }
        }
        auto query = [&](int l, int r) {
            int k = __lg(r - l);
            return min(ST[l][k], ST[r - (1 << k)][k]);
        };
        vector<ll> ans(Q, 2 * N);
        for (int i = 0; i < Q; i++) {
            int s = R[i] - L[i] + 1;
            if (one[R[i] + 1] - one[L[i]] == s) {
                ans[i] = s;
                continue;
            }
            if (one[R[i] + 1] - one[L[i]] == 0) {
                ans[i] = s * 2;
                continue;
            }
            int l = L[i], r = R[i];
            if (H[L[i]] == 1) {
                ans[i] = min(ans[i], 2LL * s - RG[L[i]] + L[i] - 1);
                l = RG[L[i]] + 1;
            }
            if (H[R[i]] == 1) {
                ans[i] = min(ans[i], 2LL * s - R[i] + LG[R[i]] - 1);
                r = LG[R[i]] - 1;
            }
            if (l <= r) {
                ans[i] = min(ans[i], query(l, r + 1) - 2LL * (L[i] + N - R[i] - 1));
            }
        }
        return ans;
    }
}

Compilation message

doll.cpp:1:10: fatal error: meetings.h: No such file or directory
    1 | #include "meetings.h"
      |          ^~~~~~~~~~~~
compilation terminated.