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>
typedef long long ll;
using namespace std;
const int maxn = 150;
bool ask(const vector<int> &v) // vrati ze ci maju nejaky dvaja ludia na tejto party rovnaky kostym
{
cout << v.size();
for (int i : v) cout << " " << i+1;
cout << endl;
int x; cin >> x;
return x < v.size();
}
void answer(const vector<int> &v)
{
cout << 0;
for (int i : v) cout << " " << i+1;
cout << endl;
}
vector<vector<int> > g(maxn);
vector<int> c;
void dfs(int u, int col)
{
c[u] = col;
for (int v : g[u]) if (c[v] == -1) dfs(v, col);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
vector<int> p(n);
iota(p.begin(), p.end(), 0);
while (ask(p))
{
int lo = 0, hi = p.size() - 1;
while (lo < hi)
{
int mi = (lo + hi) >> 1;
if (ask(vector<int>(p.begin(), p.begin() + mi + 1))) hi = mi;
else lo = mi + 1;
}
int x = lo; lo = 0, hi = x - 1;
while (lo < hi)
{
int mi = (lo + hi + 1) >> 1;
if (ask(vector<int>(p.begin() + mi, p.begin() + x + 1))) lo = mi;
else hi = mi - 1;
}
g[p[x]].push_back(p[lo]), g[p[lo]].push_back(p[x]);
p.erase(p.begin() + x);
}
int col = 0; c.assign(n, -1);
for (int i = 0; i < n; i++) if (c[i]==-1) dfs(i, col++);
answer(c);
return 0;
}
Compilation message (stderr)
carnival.cpp: In function 'bool ask(const std::vector<int>&)':
carnival.cpp:12:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | return x < v.size();
| ~~^~~~~~~~~~
# | 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... |