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;
const int N = 155;
vector<int> vec[N];
int n, color[N];
int cnt = 1;
int get(vector<int> &a) {
cout << a.size() << ' ';
for (int u : a) cout << u << ' ';
cout << endl;
int ret; cin >> ret; return ret;
}
bool inside(int l, int r, int cur) {
vector<int> a;
for (int c = l; c <= r; ++c) a.push_back(vec[c][0]);
a.push_back(cur);
int x = r - l + 1;
int y = get(a);
if (x == y) return true; // inside
else return false;
}
bool ask(int l, int r, int cur) {
if (l == r) {
if (inside(l, r, cur)) { vec[l].push_back(cur); return true; }
else return false;
}
int mid = ((l + r) >> 1);
if (inside(l, mid, cur)) return ask(l, mid, cur);
else return ask(mid + 1, r, cur);
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
vec[1].push_back(1);
for (int i = 2; i <= n; ++i) {
bool done = ask(1, cnt, i);
if (!done) {
vec[++cnt].push_back(i);
}
}
for (int i = 1; i <= cnt; ++i) {
for (int u : vec[i]) color[u] = i;
}
// output
cout << 0 << ' ';
for (int i = 1; i <= n; ++i) cout << color[i] << ' '; cout << endl;
}
# | 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... |