답안 #710882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710882 2023-03-16T03:48:02 Z ToroTN 사육제 (CEOI14_carnival) C++14
0 / 100
15 ms 208 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int n,p[155],st,md,ed,con,r,l;
set<int> s;
vector<int> v,g;
int f(int a)
{
    if(p[a]==a)
    {
        return a;
    }
    return p[a]=f(p[a]);
}
void un(int b,int c)
{p[f(b)]=f(c);}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)p[i]=i;
    while(1)
    {
        s.clear(),v.clear();
        for(int i=1;i<=n;i++)s.insert(f(i));
        for(auto it=s.begin();it!=s.end();it++)v.pb(*it);
        st=0,ed=v.size()-1;
        while(ed>=st)
        {
            g.clear();
            md=(st+ed)/2;
            for(int i=0;i<=md;i++)g.pb(v[i]);
            printf("%d ",g.size());
            for(auto node:g)printf("%d ",node);
            printf("\n");
            fflush(stdout);
            scanf("%d",&con);
            if(con==g.size())
            {
                st=md+1;
            }else
            {
                ed=md-1;
            }
        }
        r=st;
        if(r==v.size())break;
        ed=r;
        st=0;
        while(ed>=st)
        {
            g.clear();
            md=(st+ed)/2;
            for(int i=md;i<=r;i++)g.pb(v[i]);
            printf("%d ",g.size());
            for(auto node:g)printf("%d ",node);
            printf("\n");
            fflush(stdout);
            scanf("%d",&con);
            if(con==g.size())
            {
                ed=md-1;
            }else
            {
                st=md+1;
            }
        }
        l=ed;
        un(v[l],v[r]);
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ",f(i));
    }
    printf("\n");
    fflush(stdout);
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:32:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   32 |             printf("%d ",g.size());
      |                     ~^   ~~~~~~~~
      |                      |         |
      |                      int       std::vector<int>::size_type {aka long unsigned int}
      |                     %ld
carnival.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             if(con==g.size())
      |                ~~~^~~~~~~~~~
carnival.cpp:46:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         if(r==v.size())break;
      |            ~^~~~~~~~~~
carnival.cpp:54:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   54 |             printf("%d ",g.size());
      |                     ~^   ~~~~~~~~
      |                      |         |
      |                      int       std::vector<int>::size_type {aka long unsigned int}
      |                     %ld
carnival.cpp:59:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |             if(con==g.size())
      |                ~~~^~~~~~~~~~
carnival.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
carnival.cpp:36:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |             scanf("%d",&con);
      |             ~~~~~^~~~~~~~~~~
carnival.cpp:58:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |             scanf("%d",&con);
      |             ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 208 KB Same person came twice to the party.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 208 KB Same person came twice to the party.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 208 KB Same person came twice to the party.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 208 KB Same person came twice to the party.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 208 KB Same person came twice to the party.
2 Halted 0 ms 0 KB -