#include <bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;
int ask(vector<int>st) {
cout << (int)st.size() << " ";
for(auto X : st) cout << X << " ";
cout << endl;
int x;
cin >> x;
return x;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,cnt = 0;
cin >> n;
bool was[n + 1];
int res[n + 1];
vector<int>sol;
for(int i = 2; i <= n; i++) {
int l = 1,r = i - 1,ans = -1;
while(l <= r) {
int mid = (l + r) / 2;
vector<int>vec;
for(int j = mid; j <= i; j++) {
if(!was[j]) vec.pb(j);
}
if(ask(vec) != (int)vec.size()) {
ans = mid;
l = mid + 1;
}else {
r = mid - 1;
}
}
if(ans == -1) continue;
int prv = ans;
if(sol.empty()) {
res[ans] = ++cnt;
res[i] = cnt;
was[ans] = true;
was[i] = true;
sol.pb(i);
continue;
}
was[i] = true;
l = 0, r = (int)sol.size() - 1,ans = -1;
while(l <= r) {
int mid = (l + r) / 2;
vector<int>vec;
vec.pb(i);
for(int j = mid; j < (int)sol.size(); j++) vec.pb(sol[j]);
if(ask(vec) != (int)vec.size()) {
ans = mid;
l = mid + 1;
}else {
r = mid - 1;
}
}
if(ans == -1) {
res[prv] = ++cnt;
res[i] = cnt;
was[prv] = true;
was[i] = true;
sol.pb(i);
continue;
}
res[i] = res[sol[ans]];
}
for(int i = 1; i <= n; i++) if(!was[i]) res[i] = ++cnt;
cout << 0 << " ";
for(int i = 1; i <= n; i++) cout << res[i] << " ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
0 ms |
344 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |