Submission #681081

#TimeUsernameProblemLanguageResultExecution timeMemory
681081AlexandruabcdeCarnival (CEOI14_carnival)C++14
100 / 100
15 ms288 KiB
#include <bits/stdc++.h>

using namespace std;

constexpr int NMAX = 155;

vector <int> AllDifferent;

bool Question (int ind, int x) {
    cout << ind + 2 << " ";
    for (int i = 0; i <= ind; ++ i )
        cout << AllDifferent[i] << " ";
    cout << x << '\n';
    cout.flush();

    int ans;
    cin >> ans;

    return (ans == ind + 2);
}

int color[NMAX];
int N;

void BinarySearch (int x) {
    int st = 0, dr = AllDifferent.size() - 1;
    int pos = AllDifferent.size();

    while (st <= dr) {
        int mij = (st + dr) / 2;

        if (Question(mij, x)) st = mij + 1;
        else {
            dr = mij - 1;
            pos = mij;
        }
    }

    color[x] = pos+1;
    if (pos == AllDifferent.size())
        AllDifferent.push_back(x);
}

int main () {
    cin >> N;

    AllDifferent.push_back(1);
    color[1] = 1;

    for (int i = 2; i <= N; ++ i ) {
        BinarySearch(i);
    }

    cout << 0 << " ";
    for (int i = 1; i <= N; ++ i )
        cout << color[i] << " ";

    return 0;
}

Compilation message (stderr)

carnival.cpp: In function 'void BinarySearch(int)':
carnival.cpp:40:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     if (pos == AllDifferent.size())
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...