#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
#define int long long
using namespace std;
const int mod=1e9+7,mxn=1e3+5,lg=30,inf=1e18,minf=-1e18;
int pa[mxn+10],cnt=1;
int find(int u){return pa[u]==u?u:pa[u]=find(pa[u]);}
int val[mxn+10];
int32_t main(){
int n,m;cin>>n;
for(int i=1;i<=n;i++)pa[i]=i;
vector<int>v;
for(int i=1;i<=n;i++){
cout<<v.size()+1<<" ";
cout<<i<<" ";
for(auto j:v)cout<<j<<" ";
cout<<endl;
cin>>m;
if(m==v.size()+1)v.pb(i);
else{
int l=0,r=v.size()-1,pos=inf;
while(l<=r){
int mid=(l+r)/2;
cout<<mid+2<<" ";
cout<<i<<" ";
for(int j=0;j<=mid;j++)cout<<v[j]<<" ";
cout<<endl;
cin>>m;
if(m==mid+1)r=mid-1,pos=min(pos,mid);
else l=mid+1;
}
pa[i]=v[pos];
}
}
cout<<0<<" ";
for(int i=1;i<=n;i++){
int g=find(pa[i]);
if(val[g]==0)val[g]=cnt++;
cout<<val[g]<<" ";
}
cout<<endl;
return 0;
}
Compilation message
carnival.cpp:31:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
31 | #pragma GCC optimize ("03,unroll-lopps")
| ^
carnival.cpp:36:15: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
36 | int find(int u){return pa[u]==u?u:pa[u]=find(pa[u]);}
| ^
carnival.cpp:38:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
38 | int32_t main(){
| ^
carnival.cpp: In function 'int32_t main()':
carnival.cpp:48:7: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | if(m==v.size()+1)v.pb(i);
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
440 KB |
Output is correct |
4 |
Correct |
1 ms |
444 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
444 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
4 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
444 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
440 KB |
Output is correct |
4 |
Correct |
2 ms |
444 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
440 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
444 KB |
Output is correct |
4 |
Correct |
3 ms |
444 KB |
Output is correct |
5 |
Correct |
2 ms |
440 KB |
Output is correct |
6 |
Correct |
2 ms |
440 KB |
Output is correct |
7 |
Correct |
2 ms |
444 KB |
Output is correct |