답안 #409246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409246 2021-05-20T12:20:30 Z cheissmart 코알라 (APIO17_koala) C++14
24 / 100
248 ms 448 KB
#ifndef CHEISSMART
#include "koala.h"
#endif
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
    cerr << to_string(h);
    if(sizeof ...(t)) cerr << ", ";
    DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7;

int a[100], b[100];

int minValue(int N, int W) {
    for(int i = 0; i < N; i++)
        a[i] = 1;
    playRound(a, b);
    int k;
    for(int j = 0; j < N; j++)
        if(b[j] == 2)
            k = j;
    for(int i = 0; i < N; i++)
        a[i] = 0;
    a[k] = 1;
    playRound(a, b);
    for(int i = 0; i < N; i++)
        if(b[i] == 0)
            return i;
}

int maxValue(int N, int W) {
    set<int> s;
    for(int i = 0; i < N; i++)
        s.insert(i);
    while(s.size() > 1) {
        int x = s.size();
        for(int i = 0; i < N; i++) {
            if(s.count(i)) {
                a[i] = W / x;
            } else {
                a[i] = 0;
            }
        }
        s.clear();
        playRound(a, b);
        for(int i = 0; i < N; i++)
            if(b[i] == W / x + 1)
                s.insert(i);
    }
    return *s.begin();
}

int greaterValue(int N, int W) {
    int mn = minValue(N, W);
    if(mn == 0) return 1;
    else if(mn == 1) return 0;
    int more = 0;
    while(true) {
        for(int i = 0; i < N; i++)
            a[i] = 0;
        a[0] = a[1] = ++more;
        playRound(a, b);
        if(b[0] > a[0] && b[1] <= a[1])
            return 0;
        if(b[1] > a[1] && b[0] <= a[0])
            return 1;
    }
}

void allValues(int N, int W, int *P) {
    if (W == 2*N) {
        // TODO: Implement Subtask 4 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    } else {
        // TODO: Implement Subtask 5 solution here.
        // You may leave this block unmodified if you are not attempting this
        // subtask.
    }
}

Compilation message

koala.cpp: In function 'int minValue(int, int)':
koala.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
koala.cpp:47:10: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |     a[k] = 1;
      |     ~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 200 KB Output is correct
2 Correct 8 ms 200 KB Output is correct
3 Correct 10 ms 200 KB Output is correct
4 Correct 10 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 200 KB Output is correct
2 Correct 17 ms 200 KB Output is correct
3 Correct 17 ms 200 KB Output is correct
4 Correct 16 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 245 ms 324 KB Output is partially correct
2 Partially correct 248 ms 292 KB Output is partially correct
3 Partially correct 237 ms 320 KB Output is partially correct
4 Partially correct 236 ms 320 KB Output is partially correct
5 Partially correct 247 ms 448 KB Output is partially correct
6 Partially correct 238 ms 312 KB Output is partially correct
7 Partially correct 237 ms 312 KB Output is partially correct
8 Partially correct 238 ms 432 KB Output is partially correct
9 Partially correct 243 ms 308 KB Output is partially correct
10 Partially correct 231 ms 320 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 200 KB Output isn't correct
2 Halted 0 ms 0 KB -