Submission #370097

# Submission time Handle Problem Language Result Execution time Memory
370097 2021-02-23T09:02:59 Z 79brue Koala Game (APIO17_koala) C++14
90 / 100
95 ms 548 KB
#include <bits/stdc++.h>
#include "koala.h"

using namespace std;

typedef long long ll;

int minValue(int n, int w){
    int A[102] = {1};
    int B[102] = {0};
    playRound(A, B);
    for(int i=0; i<n; i++){
        if(B[i] <= A[i]) return i;
    }
    exit(1);
}

int maxValue(int n, int W) {
    vector<int> candidate;
    for(int i=0; i<n; i++) candidate.push_back(i);
    while((int)candidate.size() > 1){
        int tmp = W / (int)candidate.size();
        int A[102] = {0};
        int B[102] = {0};
        for(auto cand: candidate) A[cand] = tmp;
        playRound(A, B);

        candidate.clear();
        for(int i=0; i<n; i++) if(B[i] > tmp) candidate.push_back(i);
    }
    return candidate[0];
}

int greaterValue(int N, int W) {
    int MIN = 1, MAX = 9;
    while(MIN <= MAX){
        int MID = (MIN + MAX) / 2;

        int A[102] = {MID, MID};
        int B[102] = {0};
        playRound(A, B);
        if(B[0] > MID && B[1] > MID) MIN = MID + 1;
        else if(B[0] <= MID && B[1] <= MID) MAX = MID - 1;
        else return B[0] < B[1];
    }
    exit(1);
}

void solve(int n, int *P, int l, int r, vector<int>& v){
    if(l==r){
        P[v[0]] = l+1;
        return;
    }
    int tmp = min((int)sqrt(2*(l+1)), n / (r-l+1));

    int A[102] = {0};
    int B[102] = {0};
    for(auto i: v) A[i] = tmp;
    playRound(A, B);

    vector<int> v1, v2;
    for(auto i: v){
        if(B[i] > tmp) v2.push_back(i);
        else v1.push_back(i);
    }
    solve(n, P, l, l + (int)v1.size() - 1, v1);
    solve(n, P, r - (int)v2.size() + 1, r, v2);
}

void allValues(int N, int W, int *P) {
    vector<int> vec (N);
    for(int i=0; i<N; i++) vec[i] = i;
    solve(N, P, 0, N-1, vec);
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Correct 7 ms 364 KB Output is correct
4 Correct 6 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 364 KB Output is correct
2 Correct 18 ms 392 KB Output is correct
3 Correct 18 ms 492 KB Output is correct
4 Correct 17 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 408 KB Output is correct
2 Correct 95 ms 364 KB Output is correct
3 Correct 74 ms 364 KB Output is correct
4 Correct 71 ms 364 KB Output is correct
5 Correct 72 ms 548 KB Output is correct
6 Correct 72 ms 384 KB Output is correct
7 Correct 71 ms 364 KB Output is correct
8 Correct 74 ms 364 KB Output is correct
9 Correct 73 ms 504 KB Output is correct
10 Correct 70 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 364 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 364 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 5 ms 364 KB Output is correct
7 Correct 5 ms 492 KB Output is correct
8 Correct 5 ms 364 KB Output is correct
9 Correct 5 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 4 ms 364 KB Output is correct
13 Correct 5 ms 364 KB Output is correct
14 Correct 4 ms 364 KB Output is correct
15 Correct 5 ms 364 KB Output is correct
16 Correct 5 ms 364 KB Output is correct
17 Correct 5 ms 364 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 5 ms 492 KB Output is correct
21 Correct 5 ms 364 KB Output is correct
22 Correct 4 ms 364 KB Output is correct
23 Correct 5 ms 364 KB Output is correct
24 Correct 5 ms 492 KB Output is correct
25 Correct 5 ms 364 KB Output is correct
26 Correct 5 ms 364 KB Output is correct
27 Correct 4 ms 364 KB Output is correct
28 Correct 5 ms 364 KB Output is correct
29 Correct 5 ms 364 KB Output is correct
30 Correct 5 ms 364 KB Output is correct
31 Correct 5 ms 364 KB Output is correct
32 Correct 5 ms 364 KB Output is correct
33 Correct 4 ms 364 KB Output is correct
34 Correct 4 ms 364 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 4 ms 364 KB Output is correct
37 Correct 5 ms 364 KB Output is correct
38 Correct 5 ms 364 KB Output is correct
39 Correct 5 ms 364 KB Output is correct
40 Correct 5 ms 364 KB Output is correct