답안 #156540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156540 2019-10-06T11:53:55 Z Alexa2001 코알라 (APIO17_koala) C++17
73 / 100
70 ms 512 KB
#include "koala.h"
#include <bits/stdc++.h>

using namespace std;

const int Nmax = 105;
int a[Nmax], b[Nmax];

int minValue(int N, int W)
{
    int i;
    for(i=1; i<N; ++i) a[i] = 0;
    a[1] = 1;

    int id;
    playRound(a, b);

    for(i=0; i<N; ++i)
        if(b[i] < a[i] + 1)
            id = i;
    return id;
}

int maxValue(int N, int W)
{
    int i, step, nr = N;
    bool used[Nmax];

    for(i=0; i<N; ++i) used[i] = 1;

    for(step = 0; step < 4; ++step)
    {
        for(i=0; i<N; ++i)
            if(used[i]) a[i] = N / nr;
                else a[i] = 0;

        playRound(a, b);

        for(i=0; i<N; ++i)
            if(used[i] && b[i] <= a[i])
                used[i] = 0, --nr;
    }

    assert(nr == 1);
    for(i=0; i<N; ++i)
        if(used[i]) return i;
    assert(0);
}

bool cmp(int x, int y) /// 1 daca x < y;
{
    if(x == y) return 0;

    int l = 1, r = 9, mid;
    while(1)
    {
        mid = (l + r) / 2;

        int i;
        for(i=0; i<100; ++i) a[i] = ((i == x || i == y) ? mid : 0);

        playRound(a, b);

        bool X, Y;
        X = b[x] > a[x];
        Y = b[y] > a[y];

        if(X ^ Y)
            return Y;

        if(!X) r = mid - 1;
            else l = mid + 1;
    }
    assert(0);
}

bool cmp2(int x, int y)
{
    if(x == y) return 0;

    int i;
    for(i=0; i<100; ++i) a[i] = 0;
    a[x] = a[y] = 100;

    playRound(a, b);

    return (a[y] < b[y]);
}

int greaterValue(int N, int W)
{
    return (cmp(0, 1) ? 1 : 0);
}

void allValues(int N, int W, int *P)
{
    int i;
    for(i=0; i<N; ++i) P[i] = i;
    int ans[Nmax];

    if (W == 2*N)
        stable_sort(P, P+N, cmp2);
    else
        stable_sort(P, P+N, cmp);

    for(i=0; i<N; ++i)
        ans[P[i]] = i+1;

    for(i=0; i<N; ++i)
        P[i] = ans[i];
}

Compilation message

koala.cpp: In function 'int minValue(int, int)':
koala.cpp:21:12: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return id;
            ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 376 KB Output is correct
2 Correct 16 ms 376 KB Output is correct
3 Correct 16 ms 376 KB Output is correct
4 Correct 16 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 504 KB Output is correct
2 Correct 70 ms 428 KB Output is correct
3 Correct 60 ms 380 KB Output is correct
4 Correct 59 ms 384 KB Output is correct
5 Correct 61 ms 484 KB Output is correct
6 Correct 60 ms 432 KB Output is correct
7 Correct 60 ms 384 KB Output is correct
8 Correct 62 ms 512 KB Output is correct
9 Correct 63 ms 400 KB Output is correct
10 Correct 59 ms 424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 380 KB Output is correct
2 Correct 38 ms 376 KB Output is correct
3 Correct 38 ms 424 KB Output is correct
4 Correct 37 ms 376 KB Output is correct
5 Correct 37 ms 476 KB Output is correct
6 Correct 37 ms 384 KB Output is correct
7 Correct 37 ms 376 KB Output is correct
8 Correct 37 ms 376 KB Output is correct
9 Correct 37 ms 376 KB Output is correct
10 Correct 36 ms 392 KB Output is correct
11 Correct 38 ms 388 KB Output is correct
12 Correct 17 ms 376 KB Output is correct
13 Correct 35 ms 396 KB Output is correct
14 Correct 33 ms 384 KB Output is correct
15 Correct 33 ms 292 KB Output is correct
16 Correct 35 ms 376 KB Output is correct
17 Correct 35 ms 388 KB Output is correct
18 Correct 34 ms 376 KB Output is correct
19 Correct 35 ms 376 KB Output is correct
20 Correct 35 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 21 ms 376 KB Output is partially correct
2 Partially correct 32 ms 376 KB Output is partially correct
3 Partially correct 31 ms 376 KB Output is partially correct
4 Partially correct 30 ms 376 KB Output is partially correct
5 Partially correct 32 ms 376 KB Output is partially correct
6 Partially correct 31 ms 376 KB Output is partially correct
7 Partially correct 31 ms 376 KB Output is partially correct
8 Partially correct 31 ms 504 KB Output is partially correct
9 Partially correct 31 ms 372 KB Output is partially correct
10 Partially correct 31 ms 376 KB Output is partially correct
11 Partially correct 31 ms 376 KB Output is partially correct
12 Partially correct 15 ms 372 KB Output is partially correct
13 Partially correct 30 ms 348 KB Output is partially correct
14 Partially correct 31 ms 376 KB Output is partially correct
15 Partially correct 31 ms 376 KB Output is partially correct
16 Partially correct 32 ms 376 KB Output is partially correct
17 Partially correct 32 ms 412 KB Output is partially correct
18 Partially correct 31 ms 376 KB Output is partially correct
19 Partially correct 31 ms 376 KB Output is partially correct
20 Partially correct 31 ms 376 KB Output is partially correct
21 Partially correct 32 ms 376 KB Output is partially correct
22 Partially correct 32 ms 376 KB Output is partially correct
23 Partially correct 26 ms 376 KB Output is partially correct
24 Partially correct 30 ms 376 KB Output is partially correct
25 Partially correct 31 ms 376 KB Output is partially correct
26 Partially correct 31 ms 376 KB Output is partially correct
27 Partially correct 32 ms 376 KB Output is partially correct
28 Partially correct 31 ms 376 KB Output is partially correct
29 Partially correct 31 ms 376 KB Output is partially correct
30 Partially correct 30 ms 376 KB Output is partially correct
31 Partially correct 31 ms 376 KB Output is partially correct
32 Partially correct 32 ms 376 KB Output is partially correct
33 Partially correct 30 ms 376 KB Output is partially correct
34 Partially correct 27 ms 412 KB Output is partially correct
35 Partially correct 31 ms 504 KB Output is partially correct
36 Partially correct 30 ms 376 KB Output is partially correct
37 Partially correct 27 ms 476 KB Output is partially correct
38 Partially correct 29 ms 376 KB Output is partially correct
39 Partially correct 28 ms 376 KB Output is partially correct
40 Partially correct 30 ms 376 KB Output is partially correct