Submission #370102

# Submission time Handle Problem Language Result Execution time Memory
370102 2021-02-23T09:10:04 Z 79brue Koala Game (APIO17_koala) C++14
Compilation error
0 ms 0 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;
        static_sort(idx, idx+N, [&](int x, int y){
            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;
        }
    }
}

Compilation message

koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:79:9: error: 'static_sort' was not declared in this scope; did you mean 'static_assert'?
   79 |         static_sort(idx, idx+N, [&](int x, int y){
      |         ^~~~~~~~~~~
      |         static_assert