답안 #408984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
408984 2021-05-20T00:47:51 Z syl123456 코알라 (APIO17_koala) C++17
37 / 100
93 ms 336 KB
#include "koala.h"
#include <bits/stdc++.h>
using namespace std;
int minValue(int N, int W) {
    // TODO: Implement Subtask 1 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    int a[N], b[N];
    for (int &i : a) i = 1;
    playRound(a, b);
    int tmp = 0;
    for (int i = 0; i < N; ++i) {
        if (b[i] == 0) a[i] = 0;
        else if (tmp == 0) a[i] = 98, ++tmp;
        else if (tmp == 1) a[i] = 2, ++tmp;
        else a[i] = 0;
    }
    playRound(a, b);
    for (int i = 0; i < N; ++i)
        if (a[i] == b[i]) return i;
}
int maxValue(int N, int W) {
    // TODO: Implement Subtask 2 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    int a[N], b[N];
    vector<int> v(N);
    iota(v.begin(), v.end(), 0);
    while (v.size() > 1) {
        fill(a, a + N, 0);
        for (int i : v) a[i] = W / v.size();
        playRound(a, b);
        v.clear();
        for (int i = 0; i < N; ++i) if (b[i] > a[i] && a[i])
            v.push_back(i);
    }
    return v[0];
}

int greaterValue(int N, int W) {
    // TODO: Implement Subtask 3 solution here.
    // You may leave this function unmodified if you are not attempting this
    // subtask.
    int a[N], b[N];
    fill(a + 2, a + N, 0);
    a[0] = a[1] = 4;
    playRound(a, b);
    if (b[0] > a[0] ^ b[1] > a[1])
        return b[0] > a[0] ? 0 : 1;
    if (b[0] > a[0]) {
        fill(a, a + N, 1);
        playRound(a, b);
        if (b[0] > a[0] ^ b[1] > a[1])
            return b[0] > a[0] ? 0 : 1;
        fill(a + 2, a + N, 0);
        a[0] = a[1] = b[0] > a[0] ? 10 : 7;
        playRound(a, b);
        return b[0] > a[0] ? 0 : 1;
    }
    else {
        a[0] = a[1] = 1;
        playRound(a, b);
        if (b[0] > a[0] ^ b[1] > a[1])
            return b[0] > a[0] ? 0 : 1;
        a[0] = a[1] = 2;
        playRound(a, b);
        return b[0] > a[0] ? 0 : 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 greaterValue(int, int)':
koala.cpp:48:14: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   48 |     if (b[0] > a[0] ^ b[1] > a[1])
      |         ~~~~~^~~~~~
koala.cpp:53:18: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   53 |         if (b[0] > a[0] ^ b[1] > a[1])
      |             ~~~~~^~~~~~
koala.cpp:63:18: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   63 |         if (b[0] > a[0] ^ b[1] > a[1])
      |             ~~~~~^~~~~~
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:21:1: warning: control reaches end of non-void function [-Wreturn-type]
   21 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 220 KB Output is correct
2 Correct 9 ms 200 KB Output is correct
3 Correct 9 ms 312 KB Output is correct
4 Correct 8 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 308 KB Output is correct
2 Correct 15 ms 328 KB Output is correct
3 Correct 15 ms 336 KB Output is correct
4 Correct 15 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 308 KB Output is correct
2 Correct 88 ms 312 KB Output is correct
3 Correct 84 ms 320 KB Output is correct
4 Correct 78 ms 312 KB Output is correct
5 Correct 75 ms 308 KB Output is correct
6 Correct 77 ms 312 KB Output is correct
7 Correct 78 ms 320 KB Output is correct
8 Correct 81 ms 316 KB Output is correct
9 Correct 87 ms 328 KB Output is correct
10 Correct 82 ms 316 KB Output is 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 -