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;
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define loop(_) for (int __ = 0; __ < (_); ++__)
#define pb push_back
#define f first
#define s second
#define sz(_) ((int)_.size())
#define all(_) _.begin(), _.end()
#define lb lower_bound
#define ub upper_bound
using ll = long long;
using ld = long double;
const int N = 1e5 + 7;
const ll mod = 1e9 + 7;
int n;
struct dsu
{
int fat[N];
dsu()
{
iota(fat, fat + N, 0);
}
int find(int x) { return fat[x] = (x == fat[x] ? x : find(fat[x])); }
void link(int u, int v)
{
u = find(u), v = find(v);
if (u < v)
swap(u, v);
fat[u] = v;
}
bool same(int u, int v)
{
return find(u) == find(v);
}
} d;
int ask(vi query)
{
cout << sz(query) << " ";
for (auto u : query)
cout << u << " ";
cout << endl;
cout << flush;
int ret;
cin >> ret;
return ret;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
// freopen("in.in", "r", stdin);
#endif
cin >> n;
for (int i = 1; i <= n; ++i)
{
for (int j = i + 1; j <= n; ++j)
{
if (ask({i, j}) == 1)
{
d.link(i, j);
}
}
}
cout <<"0 ";
vector<int> col(n + 1, 0) ;
int co = 0 ;
for(int i = 1;i<= n;++ i){
int x = d.find(i) ;
if(!col[x])col[x] = ++ co ;
cout << col[x] <<" " ;
}
cout << endl;
cout << flush;
return 0;
}
# | 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... |