#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
ios_base::sync_with_stdio(0);\
cin.tie(0);\
cout.tie(0)\
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
map<vi, int> mp;
int ask(vi &v){
if(mp[v]) return mp[v];
cout << v.size() << " ";
for(int i : v){
cout << i << " ";
}
cout << endl;
int x;
cin >> x;
return mp[v] = x;
}
signed main(){
int n;
cin >> n;
int a[n + 5], pre = 0;
vi v;
for(int i = 1; i <= n; i++){
v.push_back(i);
int k = ask(v);
if(k > pre){
a[i] = k;
pre = k;
}
else{
v.pop_back();
int l = 0, r = v.size() - 1, ans = -1;
while(l < r){
int mid = (l + r) / 2;
vi tmp;
for(int i = 0; i <= mid; i++){
tmp.push_back(v[i]);
}
int pre = ask(tmp);
tmp.push_back(i);
int nw = ask(tmp);
if(nw == pre){
r = mid;
}
else{
l = mid + 1;
}
}
a[i] = a[v[l]];
}
}
cout << 0 << " ";
for(int i = 1; i <= n; i++){
cout << a[i] << " ";
}
cout << endl;
}
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:51:42: warning: unused variable 'ans' [-Wunused-variable]
51 | int l = 0, r = v.size() - 1, ans = -1;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
952 KB |
Output is correct |
2 |
Correct |
4 ms |
440 KB |
Output is correct |
3 |
Correct |
3 ms |
952 KB |
Output is correct |
4 |
Correct |
2 ms |
948 KB |
Output is correct |
5 |
Correct |
2 ms |
700 KB |
Output is correct |
6 |
Correct |
2 ms |
440 KB |
Output is correct |
7 |
Correct |
5 ms |
1212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
600 KB |
Output is correct |
2 |
Correct |
5 ms |
952 KB |
Output is correct |
3 |
Correct |
4 ms |
952 KB |
Output is correct |
4 |
Correct |
2 ms |
744 KB |
Output is correct |
5 |
Correct |
3 ms |
688 KB |
Output is correct |
6 |
Correct |
3 ms |
692 KB |
Output is correct |
7 |
Correct |
3 ms |
696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
440 KB |
Output is correct |
2 |
Correct |
3 ms |
716 KB |
Output is correct |
3 |
Correct |
5 ms |
696 KB |
Output is correct |
4 |
Correct |
2 ms |
696 KB |
Output is correct |
5 |
Correct |
3 ms |
492 KB |
Output is correct |
6 |
Correct |
3 ms |
696 KB |
Output is correct |
7 |
Correct |
4 ms |
948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
952 KB |
Output is correct |
2 |
Correct |
3 ms |
692 KB |
Output is correct |
3 |
Correct |
3 ms |
952 KB |
Output is correct |
4 |
Correct |
2 ms |
736 KB |
Output is correct |
5 |
Correct |
4 ms |
1212 KB |
Output is correct |
6 |
Correct |
3 ms |
712 KB |
Output is correct |
7 |
Correct |
4 ms |
696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
696 KB |
Output is correct |
2 |
Correct |
4 ms |
952 KB |
Output is correct |
3 |
Correct |
4 ms |
996 KB |
Output is correct |
4 |
Correct |
4 ms |
696 KB |
Output is correct |
5 |
Correct |
3 ms |
948 KB |
Output is correct |
6 |
Correct |
2 ms |
704 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |