#include <bits/stdc++.h>
using namespace std;
int tip[200];
int gazda[200];
int n;
int prasaj(int l,int r)
{
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;
int z = tip[b];
for (int q=1;q<=n;q++)
{
if (tip[q]==z) 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 (y==1)
{
for (int i=l;i<=r;i++) tip[i]=tip[l];
}
else 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,n);
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:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for (int i=0;i<grupa1.size();i++)
| ~^~~~~~~~~~~~~~
carnival.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for (int j=0;j<grupa2.size();j++)
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Partially correct |
20 ms |
592 KB |
Partially correct |
4 |
Partially correct |
31 ms |
436 KB |
Partially correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
11 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
344 KB |
Output is correct |
3 |
Correct |
13 ms |
344 KB |
Output is correct |
4 |
Partially correct |
42 ms |
428 KB |
Partially correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
15 ms |
344 KB |
Output is correct |
4 |
Partially correct |
27 ms |
344 KB |
Partially correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
436 KB |
Output is correct |
7 |
Correct |
14 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Partially correct |
33 ms |
600 KB |
Partially correct |
4 |
Partially correct |
29 ms |
592 KB |
Partially correct |
5 |
Correct |
5 ms |
344 KB |
Output is correct |
6 |
Correct |
11 ms |
344 KB |
Output is correct |
7 |
Correct |
10 ms |
440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Partially correct |
27 ms |
416 KB |
Partially correct |
4 |
Partially correct |
28 ms |
592 KB |
Partially correct |
5 |
Correct |
14 ms |
592 KB |
Output is correct |
6 |
Partially correct |
34 ms |
416 KB |
Partially correct |
7 |
Partially correct |
30 ms |
344 KB |
Partially correct |