Submission #972695

# Submission time Handle Problem Language Result Execution time Memory
972695 2024-05-01T01:34:00 Z bachhoangxuan Koala Game (APIO17_koala) C++17
100 / 100
53 ms 604 KB
#include "koala.h"
#include<bits/stdc++.h>
using namespace std;

int B[105],R[105];

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

int maxValue(int N, int W) {
    vector<int> ord(N);
    iota(ord.begin(),ord.end(),0);
    while((int)ord.size()>1){
        for(int i=0;i<N;i++) B[i]=0;
        for(int x:ord) B[x]=N/(int)ord.size();
        vector<int> nxt;
        playRound(B,R);
        for(int x:ord) if(R[x]>B[x]) nxt.push_back(x);
        swap(nxt,ord);
    }
    return ord[0];
}

int greaterValue(int N, int W) {
    vector<int> x(8);
    iota(x.begin(),x.end(),1);
    x.pop_back();x.back()++;
    int l=0,r=6;
    while(l<=r){
        int mid=(l+r)>>1,d=x[mid];
        for(int i=0;i<N;i++) B[i]=0;
        B[0]=B[1]=d;
        playRound(B,R);
        if(R[0]>d && R[1]<=d) return 0;
        else if(R[1]>d && R[0]<=d) return 1;
        if(R[0]<=d) r=mid-1;
        else l=mid+1;
    }
    return 0;
}

void allValues(int N, int W, int *P) {
    if (W == 2*N) {
        vector<int> ord(N);
        iota(ord.begin(),ord.end(),0);
        stable_sort(ord.begin(),ord.end(),[&](int x,int y){
            for(int i=0;i<N;i++) B[i]=0;
            B[x]=B[y]=N;
            playRound(B,R);
            return R[y];
        });
        for(int i=0;i<N;i++) P[ord[i]]=i+1;
    } else{
        int L=1;
        vector<int> ord(N);
        iota(ord.begin(),ord.end(),0);
        function<void(vector<int>)> dnc = [&](vector<int> p){
            if((int)p.size()==1){
                P[p[0]]=L++;
                return;
            }
            int D=min((int)sqrt(2*L),W/(int)p.size());
            for(int i=0;i<N;i++) B[i]=0;
            for(int x:p) B[x]=D;
            playRound(B,R);
            vector<int> lt,rt;
            for(int x:p){
                if(R[x]) rt.push_back(x);
                else lt.push_back(x);
            }
            dnc(lt);dnc(rt);
        };
        dnc(ord);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 344 KB Output is correct
2 Correct 10 ms 452 KB Output is correct
3 Correct 12 ms 344 KB Output is correct
4 Correct 10 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 476 KB Output is correct
2 Correct 53 ms 464 KB Output is correct
3 Correct 52 ms 344 KB Output is correct
4 Correct 47 ms 468 KB Output is correct
5 Correct 47 ms 468 KB Output is correct
6 Correct 47 ms 464 KB Output is correct
7 Correct 48 ms 456 KB Output is correct
8 Correct 47 ms 476 KB Output is correct
9 Correct 50 ms 468 KB Output is correct
10 Correct 46 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 600 KB Output is correct
2 Correct 28 ms 344 KB Output is correct
3 Correct 29 ms 424 KB Output is correct
4 Correct 27 ms 344 KB Output is correct
5 Correct 27 ms 448 KB Output is correct
6 Correct 28 ms 344 KB Output is correct
7 Correct 27 ms 344 KB Output is correct
8 Correct 28 ms 456 KB Output is correct
9 Correct 27 ms 344 KB Output is correct
10 Correct 26 ms 344 KB Output is correct
11 Correct 28 ms 344 KB Output is correct
12 Correct 12 ms 344 KB Output is correct
13 Correct 26 ms 344 KB Output is correct
14 Correct 24 ms 344 KB Output is correct
15 Correct 24 ms 344 KB Output is correct
16 Correct 28 ms 344 KB Output is correct
17 Correct 25 ms 344 KB Output is correct
18 Correct 24 ms 344 KB Output is correct
19 Correct 26 ms 452 KB Output is correct
20 Correct 25 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 356 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Correct 3 ms 400 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 356 KB Output is correct
7 Correct 3 ms 356 KB Output is correct
8 Correct 3 ms 356 KB Output is correct
9 Correct 4 ms 604 KB Output is correct
10 Correct 3 ms 356 KB Output is correct
11 Correct 3 ms 356 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 2 ms 356 KB Output is correct
14 Correct 3 ms 356 KB Output is correct
15 Correct 3 ms 356 KB Output is correct
16 Correct 3 ms 356 KB Output is correct
17 Correct 3 ms 356 KB Output is correct
18 Correct 3 ms 472 KB Output is correct
19 Correct 3 ms 356 KB Output is correct
20 Correct 3 ms 356 KB Output is correct
21 Correct 3 ms 356 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 3 ms 356 KB Output is correct
24 Correct 2 ms 356 KB Output is correct
25 Correct 3 ms 356 KB Output is correct
26 Correct 3 ms 472 KB Output is correct
27 Correct 3 ms 356 KB Output is correct
28 Correct 3 ms 344 KB Output is correct
29 Correct 3 ms 344 KB Output is correct
30 Correct 3 ms 344 KB Output is correct
31 Correct 3 ms 344 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 3 ms 464 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 3 ms 344 KB Output is correct
36 Correct 3 ms 344 KB Output is correct
37 Correct 3 ms 344 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 3 ms 344 KB Output is correct
40 Correct 2 ms 356 KB Output is correct