답안 #829837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829837 2023-08-18T15:19:31 Z GusterGoose27 코알라 (APIO17_koala) C++17
37 / 100
75 ms 464 KB
#include "koala.h"

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 105;
bool pres[MAXN];
int n, w;

vector<int> query(vector<int> &inp) {
    int *a = new int[n];
    int *b = new int[n];
    for (int i = 0; i < n; i++) a[i] = inp[i];
    playRound(a, b);
    vector<int> out;
    for (int i = 0; i < n; i++) {
        if (b[i] > inp[i]) out.push_back(i);
    }
    delete[] a;
    delete[] b;
    return out;
}

vector<int> complement(vector<int> inp) {
    fill(pres, pres+n, 0);
    for (int v: inp) pres[v] = 1;
    vector<int> out;
    for (int i = 0; i < n; i++)
        if (!pres[i]) out.push_back(i);
    return out;
}

vector<int> inter(vector<int> a, vector<int> &b) {
    fill(pres, pres+n, 0);
    for (int v: a) pres[v] = 1;
    vector<int> out;
    for (int v: b)
        if (pres[v]) out.push_back(v);
    return out;
}

int minValue(int N, int W) {
    n = N; w = W;
    vector<int> vals(n, 0);
    vals[0] = 1;
    return complement(query(vals))[0];
}

int maxValue(int N, int W) {
    n = N; w = W;
    vector<int> cur(n, 0);
    iota(cur.begin(), cur.end(), 0);
    while (cur.size() > 1) {
        int put = n/cur.size();
        vector<int> qry(n, 0);
        for (int v: cur) qry[v] = put;
        cur = inter(query(qry), cur);
    }
    return cur[0];
}

int greaterValue(int N, int W) {
    n = N; w = W;
    vector<int> put({1, 2, 5, 10});
    int mn = -1, mx = 4;
    vector<int> two({0, 1});
    while (mx > mn+1) {
        int cur = (mn+mx)/2;
        vector<int> qry(n, 0);
        qry[0] = qry[1] = put[cur];
        vector<int> vals = inter(query(qry), two);
        if (vals.size() == 2) mn = cur;
        else if (vals.empty()) mx = cur;
        else {
            return vals[0];
        }
    }
    assert(false);
    return 0;
}

void allValues(int N, int W, int *P) {
    n = N; w = W;
    if (W == 2*N) {
        // TODO: Implement Subtask 4 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    } else {
        // TODO: Implement Subtask 5 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 320 KB Output is correct
2 Correct 13 ms 324 KB Output is correct
3 Correct 16 ms 320 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 464 KB Output is correct
2 Correct 63 ms 328 KB Output is correct
3 Correct 63 ms 328 KB Output is correct
4 Correct 75 ms 320 KB Output is correct
5 Correct 60 ms 336 KB Output is correct
6 Correct 62 ms 336 KB Output is correct
7 Correct 61 ms 320 KB Output is correct
8 Correct 63 ms 328 KB Output is correct
9 Correct 64 ms 316 KB Output is correct
10 Correct 60 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 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 -