/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define vi vector<int>
using namespace std;
const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18;
int n, ans[mxN];
vi diff;
int ask(int l, int r, int idx) {
cout << r - l + 2 << " ";
for(int i = l; i <= r; ++i)
cout << diff[i] << " ";
cout << idx << endl;
int ans; cin >> ans;
return ans;
}
int binary_search(int idx) {
int l = 0, r = diff.size() - 1, ans = diff.size() + 1;
while(l <= r) {
int mid = (l + r) >> 1;
int tmp = ask(l, mid, idx);
if(tmp == mid - l + 1)
ans = mid + 1, r = mid - 1;
else
l = mid + 1;
}
if(ans == (int)diff.size() + 1)
diff.pb(idx);
return ans;
}
void solve() {
cin >> n;
diff.pb(1); ans[1] = 1;
for(int i = 2; i <= n; ++i)
ans[i] = binary_search(i);
cout << 0 << " ";
for(int i = 1; i <= n; ++i)
cout << ans[i] << " ";
cout << endl;
}
signed main() {
#ifndef CDuongg
if(fopen(taskname".inp", "r"))
assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
freopen("bai3.inp", "r", stdin);
freopen("bai3.out", "w", stdout);
auto start = chrono::high_resolution_clock::now();
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1; //cin >> t;
while(t--) solve();
#ifdef CDuongg
auto end = chrono::high_resolution_clock::now();
cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
#endif
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
208 KB |
Output is correct |
2 |
Correct |
8 ms |
208 KB |
Output is correct |
3 |
Correct |
6 ms |
208 KB |
Output is correct |
4 |
Correct |
10 ms |
324 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
7 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
8 ms |
208 KB |
Output is correct |
3 |
Correct |
8 ms |
208 KB |
Output is correct |
4 |
Correct |
10 ms |
208 KB |
Output is correct |
5 |
Correct |
5 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
208 KB |
Output is correct |
7 |
Correct |
6 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
7 ms |
208 KB |
Output is correct |
4 |
Correct |
9 ms |
208 KB |
Output is correct |
5 |
Correct |
6 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
208 KB |
Output is correct |
7 |
Correct |
9 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
7 ms |
208 KB |
Output is correct |
4 |
Correct |
5 ms |
328 KB |
Output is correct |
5 |
Correct |
8 ms |
208 KB |
Output is correct |
6 |
Correct |
8 ms |
208 KB |
Output is correct |
7 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
9 ms |
216 KB |
Output is correct |
4 |
Correct |
9 ms |
208 KB |
Output is correct |
5 |
Correct |
6 ms |
208 KB |
Output is correct |
6 |
Correct |
9 ms |
208 KB |
Output is correct |
7 |
Correct |
8 ms |
208 KB |
Output is correct |