Submission #710884

# Submission time Handle Problem Language Result Execution time Memory
710884 2023-03-16T03:49:07 Z ToroTN Carnival (CEOI14_carnival) C++14
0 / 100
17 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]);
    }
    printf("0 ");
    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);
      |             ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 208 KB Integer 133 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 208 KB Integer 142 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 208 KB Integer 133 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 208 KB Integer 143 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 208 KB Integer 149 violates the range [1, 2]
2 Halted 0 ms 0 KB -