Submission #349048

# Submission time Handle Problem Language Result Execution time Memory
349048 2021-01-16T12:21:21 Z denkendoemeer Koala Game (APIO17_koala) C++14
83 / 100
69 ms 492 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=0,p2=1;
int greaterValue(int n,int w)
{
    int st=0,dr=14,mij;
    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*(w/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=mij;
    }
}
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 5 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 19 ms 364 KB Output is correct
3 Correct 18 ms 396 KB Output is correct
4 Correct 18 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 364 KB Output is correct
2 Correct 69 ms 364 KB Output is correct
3 Correct 59 ms 364 KB Output is correct
4 Correct 63 ms 492 KB Output is correct
5 Correct 61 ms 364 KB Output is correct
6 Correct 62 ms 364 KB Output is correct
7 Correct 59 ms 364 KB Output is correct
8 Correct 61 ms 364 KB Output is correct
9 Correct 62 ms 364 KB Output is correct
10 Correct 60 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 8 ms 364 KB Output is partially correct
2 Partially correct 8 ms 364 KB Output is partially correct
3 Partially correct 8 ms 364 KB Output is partially correct
4 Partially correct 8 ms 364 KB Output is partially correct
5 Partially correct 8 ms 364 KB Output is partially correct
6 Partially correct 8 ms 364 KB Output is partially correct
7 Partially correct 8 ms 364 KB Output is partially correct
8 Partially correct 8 ms 364 KB Output is partially correct
9 Partially correct 8 ms 492 KB Output is partially correct
10 Partially correct 8 ms 364 KB Output is partially correct
11 Partially correct 8 ms 364 KB Output is partially correct
12 Partially correct 8 ms 364 KB Output is partially correct
13 Partially correct 9 ms 364 KB Output is partially correct
14 Partially correct 8 ms 364 KB Output is partially correct
15 Partially correct 8 ms 364 KB Output is partially correct
16 Partially correct 8 ms 380 KB Output is partially correct
17 Partially correct 8 ms 364 KB Output is partially correct
18 Partially correct 8 ms 364 KB Output is partially correct
19 Partially correct 8 ms 364 KB Output is partially correct
20 Partially correct 8 ms 364 KB Output is partially correct
21 Partially correct 8 ms 364 KB Output is partially correct
22 Partially correct 8 ms 364 KB Output is partially correct
23 Partially correct 8 ms 364 KB Output is partially correct
24 Partially correct 9 ms 492 KB Output is partially correct
25 Partially correct 8 ms 364 KB Output is partially correct
26 Partially correct 8 ms 364 KB Output is partially correct
27 Partially correct 8 ms 364 KB Output is partially correct
28 Partially correct 8 ms 364 KB Output is partially correct
29 Partially correct 8 ms 364 KB Output is partially correct
30 Partially correct 8 ms 364 KB Output is partially correct
31 Partially correct 8 ms 364 KB Output is partially correct
32 Partially correct 8 ms 364 KB Output is partially correct
33 Partially correct 8 ms 364 KB Output is partially correct
34 Partially correct 8 ms 364 KB Output is partially correct
35 Partially correct 8 ms 364 KB Output is partially correct
36 Partially correct 8 ms 364 KB Output is partially correct
37 Partially correct 8 ms 364 KB Output is partially correct
38 Partially correct 8 ms 364 KB Output is partially correct
39 Partially correct 8 ms 364 KB Output is partially correct
40 Partially correct 8 ms 364 KB Output is partially correct