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;
using ll = long long ;
int ataman[152];
int Get(int x) {
if ( x == ataman[x]) return x;
return ataman[x] = Get(ataman[x]);
}
void Unite(int x, int y) {
x = Get(x);
y = Get(y);
if ( x == y) return ;
if ( x > y) swap(x, y);
ataman[y] = x;
}
int Check(int l, int r) {
cout << r- l + 1 << endl;
for ( int i = l; i <= r; i ++) cout << i << " ";
cout << endl;
int x;
cin >> x;
return x;
}
int main() {
// freopen("moocast.in", "r", stdin);
// freopen("moocast.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, i, lo, hi, mid, s, p;
cin >> n;
for (i = 1; i <= n; i ++) ataman[i] = i;
for (i = 1; i+ 1 <= n; i ++) {
s = Check(i, n);
p = Check(i + 1, n);
if ( s != p) continue;
lo = i + 1;
hi = n ;
while ( lo < hi) {
mid = (lo + hi)/2;
s = Check(i, mid);
p = Check(i + 1, mid);
if ( s != p) lo = mid + 1;
else hi = mid;
}
Unite(i, lo);
}
cout << "0 ";
vector < pair < int, int > > v;
for (i = 1; i <= n; i ++) {
v.push_back({Get(i), i});
}
sort(v.begin(), v.end());
ll ans[n + 2];
s = 0;
for (i =0; i < n; i++) {
if (i == 0 || v[i].first != v[i - 1].first) s ++;
ans[v[i].second] = s;
}
for (i = 1; i <= n; i ++) cout << ans[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... |