Submission #370103

# Submission time Handle Problem Language Result Execution time Memory
370103 2021-02-23T09:10:36 Z 79brue Koala Game (APIO17_koala) C++14
90 / 100
97 ms 520 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) {
    if(W==N){
        vector<int> vec (N);
        for(int i=0; i<N; i++) vec[i] = i;
        solve(N, P, 0, N-1, vec);
    }
    else{
        int idx[102];
        for(int i=0; i<N; i++) idx[i] = i;
        int cnt = 0;
        sort(idx, idx+N, [&](int x, int y){
             assert(++cnt <= 700);
            int A[102]={0};
            int B[102]={0};
            A[x] = A[y] = N;
            playRound(A, B);
            return B[y] > N;
        });
        for(int i=0; i<N; i++){
            P[idx[i]] = i+1;
        }
    }
}
# 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 6 ms 364 KB Output is correct
4 Correct 6 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 364 KB Output is correct
2 Correct 18 ms 364 KB Output is correct
3 Correct 20 ms 364 KB Output is correct
4 Correct 19 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 520 KB Output is correct
2 Correct 97 ms 364 KB Output is correct
3 Correct 73 ms 364 KB Output is correct
4 Correct 73 ms 364 KB Output is correct
5 Correct 73 ms 364 KB Output is correct
6 Correct 73 ms 364 KB Output is correct
7 Correct 76 ms 364 KB Output is correct
8 Correct 75 ms 492 KB Output is correct
9 Correct 74 ms 364 KB Output is correct
10 Correct 74 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 388 KB Output is correct
2 Runtime error 60 ms 516 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 5 ms 364 KB Output is correct
4 Correct 5 ms 364 KB Output is correct
5 Correct 5 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 5 ms 364 KB Output is correct
8 Correct 5 ms 364 KB Output is correct
9 Correct 5 ms 364 KB Output is correct
10 Correct 5 ms 364 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 5 ms 492 KB Output is correct
13 Correct 5 ms 364 KB Output is correct
14 Correct 5 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 364 KB Output is correct
19 Correct 5 ms 364 KB Output is correct
20 Correct 5 ms 364 KB Output is correct
21 Correct 5 ms 364 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 364 KB Output is correct
25 Correct 4 ms 364 KB Output is correct
26 Correct 5 ms 364 KB Output is correct
27 Correct 5 ms 364 KB Output is correct
28 Correct 4 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 5 ms 364 KB Output is correct
34 Correct 5 ms 364 KB Output is correct
35 Correct 5 ms 364 KB Output is correct
36 Correct 6 ms 364 KB Output is correct
37 Correct 5 ms 364 KB Output is correct
38 Correct 4 ms 364 KB Output is correct
39 Correct 5 ms 364 KB Output is correct
40 Correct 5 ms 364 KB Output is correct