#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
int tip[200];
int prasaj(int l,int r,int b)
{
l--;
cout<<r-l+1<<" ";
for (int i=l;i<r;i++){
cout<<v[i]<<" ";
}
cout<<b<<endl;
int x;
cin>>x;
return x;
}
int bs(int l,int r,int t)
{
//cout<<"l="<<l<<" r="<<r<<" t="<<t<<endl;
if (l==r) return l;
int mid = (l+r)/2;
int y = prasaj(l,mid,t);
if (y==mid-l+1) return bs(l,mid,t);
else return bs(mid+1,r,t);
}
int main()
{
cin>>n;
v.push_back(1);
tip[1] = 1;
for (int i=2;i<=n;i++)
{
int x = prasaj(1,v.size(),i);
if (x == v.size()+1)
{
v.push_back(i);
tip[i] = v.size();
}
}
for (int i=1;i<=n;i++)
{
if (tip[i]==0)
{
int x=bs(1,v.size(),i);
tip[i]=x;
}
}
cout<<"0 ";
for (int i=1;i<=n;i++) cout<<tip[i]<<" ";
cout<<endl;
return 0;
}
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | if (x == v.size()+1)
| ~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
5 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
4 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
436 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |