#include <bits/stdc++.h>
using namespace std;
int tip[200];
int gazda[200];
int n;
int prasaj(int l,int r)
{
r = min(n,r);
l = min(l,n);
cout<<r-l+1<<" ";
for (int i=l;i<=r;i++) cout<<i<<" ";
cout<<endl;
int x;
cin>>x;
return x;
}
void najdi(int l,int r)
{
vector<int> grupa1,grupa2;
int mid = (l+r)/2;
bool vnatre[200];
memset(vnatre,0,sizeof(vnatre));
for (int i=l;i<=mid;i++)
{
int x = tip[i];
if (vnatre[x]==false)
{
vnatre[x]=true;
grupa1.push_back(i);
}
}
for (int i=mid+1;i<=r;i++)
{
int x = tip[i];
if (vnatre[x]==false)
{
vnatre[x]=true;
grupa2.push_back(i);
}
}
bool visited[200];
memset(visited,0,sizeof(visited));
for (int i=0;i<grupa1.size();i++)
{
for (int j=0;j<grupa2.size();j++)
{
int a=grupa1[i],b=grupa2[j];
if (visited[a] || visited[b]) continue;
cout<<"2 "<<a<<" "<<b<<endl;
int x;
cin>>x;
if (x==1)
{
visited[a]=true;
visited[b]=true;
for (int q=l;q<=r;q++)
{
if (tip[q]==tip[b]) tip[q]=tip[a];
}
}
}
}
}
int bs(int l,int r)
{
if (l==r) return 1;
int mid = (l+r)/2;
int x = bs(l,mid) + bs(mid+1,r);
int y = prasaj(l,r);
if (x!=y) najdi(l,r);
return y;
}
int stepen()
{
int x=1;
while(x<n) x*=2;
return x;
}
int main()
{
cin>>n;
for (int i=1;i<=n;i++) tip[i]=i;
bs(1,stepen());
map<int,int> pr;
int p = 1;
for (int i=1;i<=n;i++)
{
int x = tip[i];
if (pr[x]==0)
{
pr[x]=p;
p++;
}
}
cout<<0<<" ";
for (int i=1;i<=n;i++) cout<<pr[tip[i]]<<" ";
cout<<endl;
return 0;
}
Compilation message
carnival.cpp: In function 'void najdi(int, int)':
carnival.cpp:47:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for (int i=0;i<grupa1.size();i++)
| ~^~~~~~~~~~~~~~
carnival.cpp:49:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int j=0;j<grupa2.size();j++)
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
344 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |