Submission #710886

# Submission time Handle Problem Language Result Execution time Memory
710886 2023-03-16T03:50:06 Z ToroTN Carnival (CEOI14_carnival) C++14
0 / 100
18 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 ",n-f(i)+1);
    }
    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 14 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 208 KB Integer 9 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 208 KB Output is correct
2 Incorrect 18 ms 208 KB Integer 11 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 208 KB Integer 6 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 208 KB Output is correct
2 Incorrect 13 ms 208 KB Integer 25 violates the range [1, 17]
3 Halted 0 ms 0 KB -