#include <bits/stdc++.h>
using namespace std;
#define ll long long
int coun(int l, int r, int ar[]){
set<int> s;
for (int i = l; i <= r; i++){
s.insert(ar[i]);
}
return s.size();
}
string getstr(int l, int r){
string ans = "";
for (int i = l; i <= r; i++){
ans += to_string(i) + " ";
}
return ans;
}
int main()
{
int n, res, col = 2;
cin>>n;
int ar[n];
ar[0] = 1;
for (int i = 1; i < n; i++){
cout<<(i + 1)<<" "<<getstr(1, i + 1)<<endl;
cin>>res;
int c = coun(0, i - 1, ar);
if (res > c){
ar[i] = col;
col++;
continue;
}
int l = 0, r = i - 1;
while (true){
int mid = (l + r) / 2;
string s = getstr(l + 1, mid + 1) + to_string(i + 1);
cout<<(mid - l + 2)<<" "<<s<<endl;
cin>>res;
c = coun(l, mid, ar);
if (c == res){
if (c == 1){
ar[i] = ar[l];
break;
}
else{
r = mid;
}
}
else{
l = mid + 1;
}
}
}
cout<<"0 ";
for (int i = 0; i < n; i++){
cout<<ar[i]<<' ';
}
cout<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
5 ms |
436 KB |
Output is correct |
3 |
Correct |
3 ms |
440 KB |
Output is correct |
4 |
Correct |
2 ms |
432 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
5 ms |
432 KB |
Output is correct |
3 |
Correct |
2 ms |
440 KB |
Output is correct |
4 |
Correct |
2 ms |
688 KB |
Output is correct |
5 |
Correct |
5 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
6 ms |
344 KB |
Output is correct |
3 |
Correct |
5 ms |
436 KB |
Output is correct |
4 |
Correct |
2 ms |
692 KB |
Output is correct |
5 |
Correct |
5 ms |
440 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
5 ms |
432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
5 ms |
432 KB |
Output is correct |
3 |
Correct |
2 ms |
692 KB |
Output is correct |
4 |
Correct |
2 ms |
692 KB |
Output is correct |
5 |
Correct |
4 ms |
436 KB |
Output is correct |
6 |
Correct |
3 ms |
436 KB |
Output is correct |
7 |
Correct |
4 ms |
436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
432 KB |
Output is correct |
2 |
Correct |
6 ms |
432 KB |
Output is correct |
3 |
Correct |
5 ms |
436 KB |
Output is correct |
4 |
Correct |
4 ms |
688 KB |
Output is correct |
5 |
Correct |
4 ms |
432 KB |
Output is correct |
6 |
Correct |
2 ms |
432 KB |
Output is correct |
7 |
Correct |
2 ms |
692 KB |
Output is correct |