Submission #349044

# Submission time Handle Problem Language Result Execution time Memory
349044 2021-01-16T12:13:54 Z denkendoemeer Koala Game (APIO17_koala) C++14
19 / 100
57 ms 384 KB
#include "koala.h"
#include<bits/stdc++.h>
using namespace std;
int b[105],r[105];
bool viz[105];
int minValue(int n,int w)
{
    int i;
    for(i=0;i<n;i++)
        b[i]=0;
    b[0]=1;
    playRound(b,r);
    for(i=0;i<n;i++)
        if (r[i]==0)
            return i;
    return 0;
}
int maxValue(int n,int w)
{
    int buck=n;
    int i;
    for(i=0;i<n;i++)
        viz[i]=0;
    while(buck>1){
        int cost=min(13,w/buck);
        for(i=0;i<n;i++)
            if (viz[i]==0)
                b[i]=cost;
            else
                b[i]=0;
        playRound(b,r);
        for(i=0;i<n;i++)
            if (viz[i]==0 && r[i]<=b[i])
                viz[i]=1;
        buck=0;
        for(i=0;i<n;i++)
            if (viz[i]==0)
                buck++;
    }
    for(i=0;i<n;i++)
        if (viz[i]==0)
            return i;
    return 0;
}
int p1,p2;
int greaterValue(int n,int w)
{
    int st=0,dr=14,mij;
    p1=0;
    p2=1;
    while(st<dr-1){
        mij=(st+dr)/2;
        int i;
        for(i=0;i<n;i++)
            b[i]=w/n-1;
        b[p1]=mij*(w/n);
        b[p2]=mij*(2/n);
        playRound(b,r);
        int ok1=0,ok2=0;
        if (r[p1]>b[p1])
            ok1=1;
        if (r[p2]>b[p2])
            ok2=1;
        if (ok1==ok2){
            if (ok1==1)
                st=mij;
            else
                dr=mij;
        }
        else
            return ok2;
    }
    return 0;
}
int gw,gn;
bool cmp(int a,int b)
{
    if (a==b)
        return 0;
    p1=a;
    p2=b;
    return greaterValue(100,gw);
}
int ans[105];
void find(int st,int dr,vector<int>aux)
{
    if (st+1==dr){
        ans[aux[0]]=st;
        return ;
    }
    int l=0,r2=min(50,gw/(dr-st)+1),mij;
    while(l<r2-1){
        mij=(l+r2)/2;
        int i;
        for(i=0;i<gn;i++)
            b[i]=0;
        for(auto it:aux)
            b[it]=mij;
        playRound(b,r);
        bool ok1=0,ok2=0;
        for(auto it:aux){
            if (r[it]<=b[it])
                ok1=1;
            else
                ok2=1;
        }
        if (ok1 && ok2){
            vector<int>aux1,aux2;
            for(auto it:aux)
                if (r[it]<=b[it])
                    aux1.push_back(it);
                else
                    aux2.push_back(it);
            find(st,st+aux1.size(),aux1);
            find(st+aux1.size(),dr,aux2);
            return ;
        }
        if (ok1)
            r2=mij;
        else
            l=st;
    }
}
void allValues(int n,int w,int *p)
{
    gw=w;
    gn=n;
    vector<int>aux;
    int i;
    for(i=0;i<n;i++)
        aux.push_back(i);
    find(1,n+1,aux);
    for(i=0;i<n;i++)
        p[i]=ans[i];
    return ;
}
# 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 18 ms 364 KB Output is correct
2 Correct 18 ms 364 KB Output is correct
3 Correct 18 ms 364 KB Output is correct
4 Correct 17 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -