답안 #388512

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388512 2021-04-11T19:05:42 Z fadi57 사육제 (CEOI14_carnival) C++14
100 / 100
29 ms 300 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mx=200;
const int mod= 1e9+7 ;
const ll inf=1e9+5;
//***while there is life there is hope
int n;
vector<int>comp;
int par[mx]; int siz[mx];int color[mx];
void init(){

  for(int i=1;i<=n;i++){


    par[i]=i;
    siz[i]=1;
  }

  }
  int query(int l,int r,int nw){
      cout<<r-l+2<<" ";
   for(int i=l;i<=r;i++){

    cout<<comp[i]<<" ";
   }cout<<nw;cout<<endl;int x;cin>>x;

  return x;

  }
  int fin(int node){
  if(par[node]!=node){

   return par[node]=fin(par[node]);
  }
  return node;


  }
  void uni(int a,int b){

  int aa=fin(a);
  int bb=fin(b);
  if(aa==bb){return;}

  if(siz[aa]>siz[bb]){
    swap(aa,bb);
  }
  par[aa]=bb;
  siz[bb]+=siz[aa];

  }

int main() {
 cin>>n;
 init();
 comp.push_back(1);
 int s=0;
 for(int i=2;i<=n;i++){
       int r=comp.size();
  int z=  query(0,r-1,i);
 if(z==(r+1)){

    comp.push_back(i);
 }else{


 for(auto it:comp){
    cout<<2<<" "<<i<<" "<<it<<endl;
    int ans;cin>>ans;
    if(ans==1){

        uni(i,it);
        break;
    }
 }
  }


 }
 int f=1;

 for(auto it:comp){

    color[it]=f;
    f++;

 }

int ans[n+1];

cout<<0;
for(int i=1;i<=n;i++){
    int me=fin(i);

    ans[i]=color[me];
    cout<<" "<<ans[i];

 }cout<<endl;



 }

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:59:6: warning: unused variable 's' [-Wunused-variable]
   59 |  int s=0;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 200 KB Output is correct
2 Correct 23 ms 200 KB Output is correct
3 Correct 22 ms 200 KB Output is correct
4 Correct 5 ms 200 KB Output is correct
5 Correct 5 ms 200 KB Output is correct
6 Correct 4 ms 200 KB Output is correct
7 Correct 12 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 200 KB Output is correct
2 Correct 14 ms 200 KB Output is correct
3 Correct 15 ms 200 KB Output is correct
4 Correct 11 ms 200 KB Output is correct
5 Correct 5 ms 200 KB Output is correct
6 Correct 4 ms 200 KB Output is correct
7 Correct 6 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 200 KB Output is correct
2 Correct 10 ms 200 KB Output is correct
3 Correct 18 ms 200 KB Output is correct
4 Correct 7 ms 200 KB Output is correct
5 Correct 4 ms 200 KB Output is correct
6 Correct 4 ms 200 KB Output is correct
7 Correct 22 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 252 KB Output is correct
2 Correct 9 ms 200 KB Output is correct
3 Correct 28 ms 272 KB Output is correct
4 Correct 4 ms 300 KB Output is correct
5 Correct 5 ms 200 KB Output is correct
6 Correct 6 ms 200 KB Output is correct
7 Correct 20 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 200 KB Output is correct
2 Correct 18 ms 200 KB Output is correct
3 Correct 29 ms 200 KB Output is correct
4 Correct 19 ms 200 KB Output is correct
5 Correct 5 ms 200 KB Output is correct
6 Correct 4 ms 200 KB Output is correct
7 Correct 11 ms 200 KB Output is correct