#include <iostream>
using namespace std;
const int MAXN = 155;
int counter = 1;
int arr[MAXN];
int visited[MAXN];
int sz;
int n;
bool check(int l,int r,int i){
cout<<r-l+2<<" ";
cout<<i<<" ";
for(int i=l;i<=r;i++){
cout<<arr[i]<<" ";
}
cout<<endl;
cout.flush();
int x;
cin>>x;
if(x == r-l+2){
return false;
}
return true;
}
int main(){
cin>>n;
sz = 2;
visited[1] = 1;
arr[1] = 1;
for(int i=2;i<=n;i++){
cout<<sz<<" ";
for(int j=1;j<sz;j++){
cout<<arr[j]<<" ";
}
cout<<i<<" ";
cout.flush();
cout<<endl;
int x;
cin>>x;
if(x == sz){
arr[sz] = i;
visited[i] = sz;
sz++;
}
}
for(int i=1;i<=n;i++){
if(visited[i]){
continue;
}
int l=1;
int r = sz-1;
int ans = 1;
while(l<=r){
int mid = (l+r)/2;
if(check(l,mid,i)){
r = mid-1;
ans = mid;
}else{
l=mid+1;
}
}
visited[i] =ans;
}
cout<<0<<" ";
for(int i=1;i<=n;i++){
cout<<visited[i]<<" ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
9 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
10 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
8 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
10 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
10 ms |
384 KB |
Output is correct |
6 |
Correct |
10 ms |
256 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
9 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
384 KB |
Output is correct |
7 |
Correct |
10 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
412 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
256 KB |
Output is correct |