답안 #343244

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
343244 2021-01-03T15:03:29 Z blue 사육제 (CEOI14_carnival) C++11
100 / 100
11 ms 492 KB
#include <iostream>
#include <vector>
using namespace std;

vector<int> unique_set;

int binary_search(int person, int a, int b)
{
    if(a == b) return a+1;

    int m = (a+b)/2;

    cout << m-a+2 << ' ';
    for(int i = a; i <= m; i++) cout << unique_set[i] << ' ';
    cout << person << ' ';
    cout << endl;

    int res;
    cin >> res;

    if(res == m-a+1) return binary_search(person, a, m);
    else return binary_search(person, m+1, b);
}

int main()
{
    int N;
    cin >> N;

    vector<int> col(N+1, 0);

    cout << N << ' ';
    for(int i = 1; i <= N; i++) cout << i << ' ';
    cout << endl;

    int C;
    cin >> C;

    int res;


    vector<int> enabled(N+1, 1);
    int enabled_count = N;

    for(int i = 1; i <= N; i++)
    {
        if(!enabled[i]) continue;

        enabled_count--;
        enabled[i] = 0;

        if(enabled_count == 0)
        {
            enabled[i] = 1;
            unique_set.push_back(i);
            break;
        }

        cout << enabled_count << ' ';
        for(int j = 1; j <= N; j++)
        {
            if(!enabled[j]) continue;
            cout << j << ' ';
        }
        cout << endl;

        cin >> res;
        if(res != C)
        {
            enabled_count++;
            enabled[i] = 1;
            unique_set.push_back(i);
        }
    }

    for(int i = 0; i < C; i++) col[unique_set[i]] = i+1;

    for(int i = 1; i <= N; i++)
    {
        if(enabled[i]) continue;
        col[i] = binary_search(i, 0, C-1);
    }

    cout << "0 ";
    for(int i = 1; i <= N; i++) cout << col[i] << ' ';
    cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 6 ms 364 KB Output is correct
4 Correct 4 ms 364 KB Output is correct
5 Correct 5 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 5 ms 364 KB Output is correct
4 Correct 6 ms 364 KB Output is correct
5 Correct 8 ms 364 KB Output is correct
6 Correct 7 ms 364 KB Output is correct
7 Correct 10 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 6 ms 364 KB Output is correct
4 Correct 5 ms 364 KB Output is correct
5 Correct 8 ms 364 KB Output is correct
6 Correct 11 ms 364 KB Output is correct
7 Correct 8 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 364 KB Output is correct
2 Correct 7 ms 364 KB Output is correct
3 Correct 8 ms 364 KB Output is correct
4 Correct 5 ms 364 KB Output is correct
5 Correct 8 ms 364 KB Output is correct
6 Correct 8 ms 236 KB Output is correct
7 Correct 11 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 7 ms 364 KB Output is correct
7 Correct 6 ms 364 KB Output is correct