Submission #1090282

# Submission time Handle Problem Language Result Execution time Memory
1090282 2024-09-18T07:20:55 Z alexander707070 Koala Game (APIO17_koala) C++14
90 / 100
45 ms 1068 KB
#include<bits/stdc++.h>
#define MAXN 107
#include "koala.h"

using namespace std;

int b[MAXN],r[MAXN];

int minValue(int N, int W) {
    b[0]=1;
    playRound(b,r);

    for(int i=0;i<N;i++){
        if(r[i]==0)return i;
    }
    return 0;
}

vector<int> can,best;

void reset(){
    best.clear(); can.clear();
    for(int i=0;i<100;i++)b[i]=0;
}

int maxValue(int N, int W) {
    reset();

    for(int i=0;i<100;i++)can.push_back(i);
    
    while(can.size()>1){
        for(int i=0;i<100;i++)b[i]=0;

        for(int i:can){
            b[i]=W/int(can.size());
        }

        playRound(b,r);

        for(int i:can){
            if(r[i]>b[i])best.push_back(i);
        }

        can=best; best={};
    }

    return can[0];
}

int from[MAXN],to[MAXN];

bool compare(int x,int y){
    for(int i=0;i<100;i++)b[i]=0;
    
    int ll=0,rr=10,tt;

    while(ll+1<rr){
        tt=(ll+rr)/2;

        b[x]=b[y]=tt;
        playRound(b,r);

        if(r[x]<=tt and r[y]<=tt){
            rr=tt;
        }else if(r[x]>tt and r[y]>tt){
            ll=tt;
        }else{
            if(r[x]>=tt)return false;
            else return true;
        }
    }

    return false;
}

int greaterValue(int N, int W) {

    if(compare(0,1))return 1;
    else return 0;
}

int ans[107][107];

int calc(int l,int r){

    int rest=(r-l+1);

    for(int i=1;i<=100/(r-l+1);i++){

        int z=rest/(i+1);
        if(z>=r-l+1)continue;

        rest%=(i+1);
        int curr=r-z,rem=0,pt=1;

        while(rest<i+1 and rem<curr and pt<l){
            rem+=pt; pt++; rest++;
            if(rem<=curr and rest==i+1){
                rest=0; rem-=curr; curr--; z++;
            }
        }

        if(z>=r-l+1)continue;

        return i;
    }
}

vector<int> solve(vector<int> w,int mins){
    if(w.size()<=1)return w;

    int pivot=calc(mins,mins+w.size()-1);

    for(int i=0;i<100;i++)b[i]=0;
    for(int i:w)b[i]=pivot;

    playRound(b,r);

    vector<int> ll,rr;
    for(int i:w){
        if(r[i]>pivot){
            rr.push_back(i);
        }else{
            ll.push_back(i);
        }
    }

    ll=solve(ll,mins);
    rr=solve(rr,mins+ll.size());

    vector<int> res;
    for(int i:ll)res.push_back(i);
    for(int i:rr)res.push_back(i);

    return res;
}

vector<int> s;

void allValues(int N, int W, int *P) {
    s={};
    for(int i=0;i<100;i++){
        s.push_back(i);
    }

    s=solve(s,1);

    for(int i=0;i<N;i++){
        P[s[i]]=i+1;
    }
}

Compilation message

koala.cpp: In function 'int calc(int, int)':
koala.cpp:107:1: warning: control reaches end of non-void function [-Wreturn-type]
  107 | }
      | ^
# 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 9 ms 344 KB Output is correct
2 Correct 9 ms 344 KB Output is correct
3 Correct 10 ms 344 KB Output is correct
4 Correct 10 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 344 KB Output is correct
2 Correct 45 ms 344 KB Output is correct
3 Correct 37 ms 344 KB Output is correct
4 Correct 37 ms 344 KB Output is correct
5 Correct 38 ms 344 KB Output is correct
6 Correct 38 ms 344 KB Output is correct
7 Correct 38 ms 344 KB Output is correct
8 Correct 38 ms 344 KB Output is correct
9 Correct 39 ms 344 KB Output is correct
10 Correct 38 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 1068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 2 ms 464 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 3 ms 464 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 3 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 4 ms 460 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 3 ms 464 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 2 ms 344 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 2 ms 344 KB Output is correct
26 Correct 2 ms 344 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 3 ms 344 KB Output is correct
31 Correct 3 ms 344 KB Output is correct
32 Correct 2 ms 344 KB Output is correct
33 Correct 3 ms 344 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 3 ms 344 KB Output is correct
36 Correct 2 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 344 KB Output is correct