#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
#define int long long
using i64 = long long;
template <class F, class _S>
bool chmin(F &u, const _S &v){
bool flag = false;
if ( u > v ){
u = v; flag |= true;
}
return flag;
}
template <class F, class _S>
bool chmax(F &u, const _S &v){
bool flag = false;
if ( u < v ){
u = v; flag |= true;
}
return flag;
}
int query(auto a){
cout << a.size() << ' ';
for ( auto &x: a ){
cout << x + 1 << " ";
} cout << ln;
int c; cin >> c;
return c;
}
void answer(auto &a){
cout << "0 ";
for ( auto &x: a ){
cout << x << " ";
} exit(0);
}
signed main(){
// ios_base::sync_with_stdio(false);
// cin.tie(nullptr);
int n; cin >> n;
vector <vector<int>> a;
auto f = [&](int l, int r, int q){
vector <int> t(1, q);
for ( int i = l; i < r; i++ ){
t.pb(a[i].back());
}
return query(t);
};
for ( int i = 0; i < n; i++ ){
if ( f(0, (int)a.size(), i) == a.size() + 1 ){
a.pb({i});
continue;
}
int l = 0, r = (int)a.size() - 1;
while ( l < r ){
int md = (l + r) >> 1;
if ( f(l, md, i) == md - l + 2 ){
l = md + 1;
} else r = md;
}
a[l].pb(i);
}
vector <int> c(n);
int it = 0;
for ( auto &x: a ){
++it;
for ( auto &i: x ){
c[i] = it;
}
}
answer(c);
cout << '\n';
}
Compilation message
carnival.cpp:31:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
31 | int query(auto a){
| ^~~~
carnival.cpp:40:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
40 | void answer(auto &a){
| ^~~~
carnival.cpp: In function 'int main()':
carnival.cpp:61:37: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | if ( f(0, (int)a.size(), i) == a.size() + 1 ){
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
440 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
436 KB |
Output is correct |
2 |
Incorrect |
2 ms |
692 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
436 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |