답안 #75827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75827 2018-09-11T08:35:48 Z faustaadp 코알라 (APIO17_koala) C++17
92 / 100
67 ms 828 KB
#include "koala.h"
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll i;
int minValue(int N, int W) {
    int a[110],b[110];
    for(i=0;i<N;i++)
        a[i]=0;
    a[0]=1;
    playRound(a,b);
    for(i=0;i<N;i++)
        if(b[i]==0)
            return i;
    return 0;
}

int maxValue(int N, int W) {
    ll VS,K;
    int a[110],b[110];
    vector<ll> v;
    for(i=0;i<N;i++)
        v.pb(i);
    VS=N;
    K=1;
    while(VS>1)
    {
        vector<ll> vv;
        for(i=0;i<N;i++)
            a[i]=0;
        K=W/VS;
        for(i=0;i<VS;i++)
            a[v[i]]=K;
        playRound(a,b);
        for(i=0;i<N;i++)
            if(b[i]>K)
                vv.pb(i);
        v=vv;
        VS=v.size();
    }
    return v[0];
}
ll L,R,C;
int greaterValue(int N, int W) {
    int a[110],b[110];
    for(i=0;i<N;i++)
        a[i]=0;
    L=1;
    R=min(14,N/2);
    while(L<=R)
    {
        C=(L+R)/2;
        a[0]=C;
        a[1]=C;
        playRound(a,b);
        //cout<<i<<" "<<b[0]<<" "<<b[1]<<"\n";
        if(b[0]>b[1])return 0;
        if(b[0]<b[1])return 1;
        if(b[0]>C)L=C+1;
        else   R=C-1;
    }
    return 0;
}
bool gol (ll aa,ll bb,ll cc,ll dd)
{
    if((cc-bb)>dd)
        return 1;
    while(1)
    {
        if(cc<=dd)return 0;
        ll ii,H=0;
        for(ii=bb;ii>=bb-dd;ii--)
            H+=max(ii,0LL);
        if(H<aa)return 1;
        bb-=(dd+1);
        cc-=(dd+1);
    }

}
void allValues(int N, int W, int *P) {
    if (W == 2*N) {
        ll VS,K;
        int a[110],b[110],sud[110];
        for(i=0;i<N;i++)
            sud[i]=0;
        ll j;
        for(j=N-1;j>=0;j--)
        {
            vector<ll> v;
            for(i=0;i<N;i++)
                if(!sud[i])
                    v.pb(i);
            VS=j+1;
            K=2;
            while(VS>1)
            {
                vector<ll> vv;
                for(i=0;i<N;i++)
                    a[i]=0;
                K=W/VS;
                for(i=0;i<VS;i++)
                    a[v[i]]=K;
                playRound(a,b);
                for(i=0;i<N;i++)
                    if(b[i]>K&&a[i]==K)
                        vv.pb(i);
                v=vv;
                VS=v.size();
            }
            sud[v[0]]=1;
            P[v[0]]=j+1;
        }
    } else {
        ll VS,K;
        int a[110],b[110],sud[110];
        for(i=0;i<N;i++)
            sud[i]=0;
        ll j,TTT=0;
        vector<ll> v2;
        for(j=N-1;j>=0;j--)
        {
            int TTT=0;
            vector<ll> v;
            if(v2.empty())
            {
                for(i=0;i<N;i++)
                    if(!sud[i])
                        v.pb(i);
            }
            else
            {
                for(i=0;i<v2.size();i++)
                    if(!sud[v2[i]])
                        v.pb(v2[i]);
            }
            VS=v.size();
            K=1;
            v2.clear();
            while(VS>1)
            {
                vector<ll> vv;
                for(i=0;i<N;i++)
                    a[i]=0;
                K=1;
                for(i=(W/VS);i>=0;i--)
                    if(gol(j+1,j+1-VS,(W-(N-(j+1))),i))
                    {
                        K=i;
                        break;
                    }
                for(i=0;i<VS;i++)
                    a[v[i]]=K;
          //      cout<<j<<" "<<VS<<" "<<K<<"\n";
                TTT++;
                playRound(a,b);
                for(i=0;i<N;i++)
                    if(b[i]>K&&a[i]==K)
                        vv.pb(i);
                v=vv;
                VS=v.size();
                if(VS>1)
                {
                    v2=v;
                }
            }
            //cout<<j<<" "<<TTT<<"\n";
            sud[v[0]]=1;
            P[v[0]]=j+1;
        }
       // cout<<TTT<<"\n";
    }
}

Compilation message

koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:136:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(i=0;i<v2.size();i++)
                         ~^~~~~~~~~~
koala.cpp:122:14: warning: unused variable 'TTT' [-Wunused-variable]
         ll j,TTT=0;
              ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 7 ms 500 KB Output is correct
3 Correct 7 ms 500 KB Output is correct
4 Correct 7 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 520 KB Output is correct
2 Correct 19 ms 552 KB Output is correct
3 Correct 19 ms 616 KB Output is correct
4 Correct 16 ms 740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 744 KB Output is correct
2 Correct 62 ms 744 KB Output is correct
3 Correct 52 ms 744 KB Output is correct
4 Correct 62 ms 756 KB Output is correct
5 Correct 57 ms 756 KB Output is correct
6 Correct 58 ms 784 KB Output is correct
7 Correct 54 ms 784 KB Output is correct
8 Correct 56 ms 784 KB Output is correct
9 Correct 63 ms 784 KB Output is correct
10 Correct 62 ms 784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 784 KB Output is correct
2 Correct 42 ms 784 KB Output is correct
3 Correct 41 ms 784 KB Output is correct
4 Correct 63 ms 784 KB Output is correct
5 Correct 41 ms 784 KB Output is correct
6 Correct 42 ms 784 KB Output is correct
7 Correct 42 ms 784 KB Output is correct
8 Correct 38 ms 784 KB Output is correct
9 Correct 39 ms 784 KB Output is correct
10 Correct 38 ms 784 KB Output is correct
11 Correct 43 ms 784 KB Output is correct
12 Correct 42 ms 820 KB Output is correct
13 Correct 43 ms 820 KB Output is correct
14 Correct 38 ms 820 KB Output is correct
15 Correct 44 ms 820 KB Output is correct
16 Correct 38 ms 820 KB Output is correct
17 Correct 67 ms 820 KB Output is correct
18 Correct 40 ms 820 KB Output is correct
19 Correct 38 ms 820 KB Output is correct
20 Correct 38 ms 820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 8 ms 820 KB Output is partially correct
2 Partially correct 9 ms 820 KB Output is partially correct
3 Partially correct 9 ms 828 KB Output is partially correct
4 Partially correct 9 ms 828 KB Output is partially correct
5 Partially correct 8 ms 828 KB Output is partially correct
6 Partially correct 8 ms 828 KB Output is partially correct
7 Partially correct 15 ms 828 KB Output is partially correct
8 Partially correct 8 ms 828 KB Output is partially correct
9 Partially correct 9 ms 828 KB Output is partially correct
10 Partially correct 8 ms 828 KB Output is partially correct
11 Partially correct 9 ms 828 KB Output is partially correct
12 Partially correct 9 ms 828 KB Output is partially correct
13 Partially correct 9 ms 828 KB Output is partially correct
14 Partially correct 10 ms 828 KB Output is partially correct
15 Partially correct 8 ms 828 KB Output is partially correct
16 Partially correct 10 ms 828 KB Output is partially correct
17 Partially correct 9 ms 828 KB Output is partially correct
18 Partially correct 8 ms 828 KB Output is partially correct
19 Partially correct 10 ms 828 KB Output is partially correct
20 Partially correct 8 ms 828 KB Output is partially correct
21 Partially correct 9 ms 828 KB Output is partially correct
22 Partially correct 8 ms 828 KB Output is partially correct
23 Partially correct 9 ms 828 KB Output is partially correct
24 Partially correct 9 ms 828 KB Output is partially correct
25 Partially correct 9 ms 828 KB Output is partially correct
26 Partially correct 10 ms 828 KB Output is partially correct
27 Partially correct 9 ms 828 KB Output is partially correct
28 Partially correct 9 ms 828 KB Output is partially correct
29 Partially correct 9 ms 828 KB Output is partially correct
30 Partially correct 9 ms 828 KB Output is partially correct
31 Partially correct 9 ms 828 KB Output is partially correct
32 Partially correct 9 ms 828 KB Output is partially correct
33 Partially correct 9 ms 828 KB Output is partially correct
34 Partially correct 9 ms 828 KB Output is partially correct
35 Partially correct 9 ms 828 KB Output is partially correct
36 Partially correct 9 ms 828 KB Output is partially correct
37 Partially correct 9 ms 828 KB Output is partially correct
38 Partially correct 9 ms 828 KB Output is partially correct
39 Partially correct 8 ms 828 KB Output is partially correct
40 Partially correct 9 ms 828 KB Output is partially correct