#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 |
1 |
Correct |
9 ms |
452 KB |
Output is correct |
2 |
Correct |
8 ms |
452 KB |
Output is correct |
3 |
Correct |
5 ms |
452 KB |
Output is correct |
4 |
Correct |
3 ms |
456 KB |
Output is correct |
5 |
Correct |
14 ms |
448 KB |
Output is correct |
6 |
Correct |
13 ms |
440 KB |
Output is correct |
7 |
Correct |
9 ms |
444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
456 KB |
Output is correct |
2 |
Correct |
10 ms |
452 KB |
Output is correct |
3 |
Correct |
3 ms |
448 KB |
Output is correct |
4 |
Correct |
3 ms |
452 KB |
Output is correct |
5 |
Correct |
13 ms |
452 KB |
Output is correct |
6 |
Correct |
12 ms |
440 KB |
Output is correct |
7 |
Correct |
11 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
448 KB |
Output is correct |
3 |
Correct |
9 ms |
444 KB |
Output is correct |
4 |
Correct |
3 ms |
456 KB |
Output is correct |
5 |
Correct |
9 ms |
460 KB |
Output is correct |
6 |
Correct |
8 ms |
448 KB |
Output is correct |
7 |
Correct |
10 ms |
428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
440 KB |
Output is correct |
2 |
Correct |
10 ms |
456 KB |
Output is correct |
3 |
Correct |
6 ms |
456 KB |
Output is correct |
4 |
Correct |
3 ms |
448 KB |
Output is correct |
5 |
Correct |
8 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
452 KB |
Output is correct |
7 |
Correct |
9 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
440 KB |
Output is correct |
2 |
Correct |
12 ms |
440 KB |
Output is correct |
3 |
Correct |
7 ms |
448 KB |
Output is correct |
4 |
Correct |
7 ms |
452 KB |
Output is correct |
5 |
Correct |
7 ms |
452 KB |
Output is correct |
6 |
Correct |
5 ms |
456 KB |
Output is correct |
7 |
Correct |
3 ms |
452 KB |
Output is correct |