답안 #536497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
536497 2022-03-13T12:36:13 Z KoD 코알라 (APIO17_koala) C++17
19 / 100
16 ms 464 KB
#include <bits/stdc++.h>
#include "koala.h"

using std::vector;
using std::array;
using std::pair;
using std::tuple;

int minValue(int N, int) {
    int B[100] = {}, R[100] = {};
    B[0] = 1;
    playRound(B, R);
    for (int i = 1; i < N; ++i) {
        if (R[i] == 0) {
            return i;
        }
    }
    return 0;
}

int maxValue(int N, int W) {
    int B[100] = {}, R[100] = {};
    vector<int> v(N);
    std::iota(v.begin(), v.end(), 0);
    while (v.size() > 1) {
        std::fill(B, B + N, 0);
        for (const int i : v) {
            B[i] = W / v.size();
        }
        playRound(B, R);
        vector<int> next;
        for (const int i : v) {
            if (R[i] > B[i]) {
                next.push_back(i);
            }
        }
        v = std::move(next);
    }
    return v[0];
}

int greaterValue(int, int) {
    // TODO: Implement Subtask 3 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    return 0;
}

void allValues(int N, int W, int *P) {
    if (W == 2*N) {
        // TODO: Implement Subtask 4 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    } else {
        int B[100] = {}, R[100] = {};
        auto dfs = [&](auto&& dfs, const int l, vector<int>&& v) -> void {
            if (v.size() == 1) {
                P[v[0]] = l;   
            } else {
                std::fill(B, B + N, 0);
                const int w = std::min<int>(W / v.size(), std::sqrt(2 * l));
                for (const int i : v) {
                    B[i] = w;
                }
                playRound(B, R);
                vector<int> a, b;
                for (const int i : v) {
                    (R[i] <= B[i] ? a : b).push_back(i);
                }
                dfs(dfs, l, std::move(a));
                dfs(dfs, l + a.size(), std::move(b));
            }
        };
        vector<int> v(N);
        std::iota(v.begin(), v.end(), 0);
        dfs(dfs, 0, std::move(v));
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 312 KB Output is correct
2 Correct 13 ms 316 KB Output is correct
3 Correct 16 ms 316 KB Output is correct
4 Correct 11 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -