Submission #27648

# Submission time Handle Problem Language Result Execution time Memory
27648 2017-07-13T11:11:25 Z samir_droubi Carnival (CEOI14_carnival) C++14
100 / 100
29 ms 2020 KB
#include <bits/stdc++.h>
using namespace std;
const int mxn=155;
int ty[mxn];
int n;
int sz=0;
int query(int l,int r)
{
  int nm=0;
  for(int i=l;i<=r;++i)
  {
    if(ty[i]==0)
      ++nm;
  }
  printf("%d",nm);
  for(int i=l;i<=r;++i)
  {
    if(ty[i]==0)
      printf(" %d",i);
  }
  printf("\n");
  fflush(stdout);
  int ans;
  scanf("%d",&ans);
  return ans;
}
int bs(int num)
{
  int l=1;
  int r=n;
  int in=-1;
  while(l<=r)
  {
    int md=(l+r)/2;
    int x=query(1,md);
    if(x>num)
      r=md-1;
    else 
    {
      l=md+1;
      in=md;
    }
  }
  return in;
}
int main()
{
  scanf("%d",&n);
  sz=query(1,n)-1;
  int cur=1;
  while(sz)
  {
    while(true)
    {
      int in=bs(sz);
      if(in==n)break;
      ty[in+1]=cur;
    }
    ++cur;
    --sz;
  }
  for(int i=1;i<=n;++i)
  {
    if(ty[i]==0)
      ty[i]=cur;
  }

  printf("0");
  for(int i=1;i<=n;++i)
    printf(" %d",ty[i]);
  return 0;
}

Compilation message

carnival.cpp: In function 'int query(int, int)':
carnival.cpp:24:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&ans);
                   ^
carnival.cpp: In function 'int main()':
carnival.cpp:48:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 13 ms 2020 KB Output is correct
3 Correct 26 ms 2020 KB Output is correct
4 Correct 13 ms 2020 KB Output is correct
5 Correct 6 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 13 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2020 KB Output is correct
2 Correct 16 ms 2020 KB Output is correct
3 Correct 23 ms 2020 KB Output is correct
4 Correct 26 ms 2020 KB Output is correct
5 Correct 9 ms 2020 KB Output is correct
6 Correct 6 ms 2020 KB Output is correct
7 Correct 13 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 6 ms 2020 KB Output is correct
3 Correct 13 ms 2020 KB Output is correct
4 Correct 23 ms 2020 KB Output is correct
5 Correct 6 ms 2020 KB Output is correct
6 Correct 6 ms 2020 KB Output is correct
7 Correct 16 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2020 KB Output is correct
2 Correct 6 ms 2020 KB Output is correct
3 Correct 29 ms 2020 KB Output is correct
4 Correct 16 ms 2020 KB Output is correct
5 Correct 9 ms 2020 KB Output is correct
6 Correct 13 ms 2020 KB Output is correct
7 Correct 26 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2020 KB Output is correct
2 Correct 16 ms 2020 KB Output is correct
3 Correct 19 ms 2020 KB Output is correct
4 Correct 26 ms 2020 KB Output is correct
5 Correct 19 ms 2020 KB Output is correct
6 Correct 9 ms 2020 KB Output is correct
7 Correct 16 ms 2020 KB Output is correct