# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681081 | Alexandruabcde | Carnival (CEOI14_carnival) | C++14 | 15 ms | 288 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |