답안 #166532

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166532 2019-12-02T17:31:21 Z Lawliet 사육제 (CEOI14_carnival) C++14
100 / 100
11 ms 380 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 150;

int n;
int qtdGroups;

int myGroup[MAXN];

vector< int > costumes;
vector< int > curQuery;

vector< int > group[MAXN];

int query(int t)
{
  if( t == 0 ) swap( curQuery , costumes );

  printf("%d ",curQuery.size());

  for(int i = 0 ; i < curQuery.size() ; i++)
    printf("%d ",curQuery[i]);

  printf("\n");
  fflush( stdout );

  int a;
  scanf("%d",&a);

  if( t == 0 ) swap( curQuery , costumes );

  return a;
}

void createGroup(int i)
{
  myGroup[ i ] = ++qtdGroups;
  group[ qtdGroups ].push_back( i );
}

int bs(int k)
{
  int l = 0;
  int r = costumes.size() - 1;

  while( l < r )
  {
    int m = ( l + r )/2;

    curQuery.clear();

    for(int i = l ; i <= m ; i++)
      curQuery.push_back( costumes[i] );

    int qtd = curQuery.size();

    curQuery.push_back( k );

    if( query( 1 ) != qtd ) l = m + 1;
    else r = m;
  }

  return l;
}

int main()
{
 scanf("%d",&n);

 createGroup( 1 );
 costumes.push_back( 1 );

 for(int i = 2 ; i <= n ; i++)
 {
   int qtd = costumes.size();

   costumes.push_back( i );

   if( query( 0 ) != qtd ) createGroup( i );
   else
   {
     costumes.pop_back();
     myGroup[ i ] = myGroup[ costumes[ bs(i) ] ];
   }
 }

 printf("0 ");

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

Compilation message

carnival.cpp: In function 'int query(int)':
carnival.cpp:21:31: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
   printf("%d ",curQuery.size());
                ~~~~~~~~~~~~~~~^
carnival.cpp:23:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0 ; i < curQuery.size() ; i++)
                   ~~^~~~~~~~~~~~~~~~~
carnival.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a);
   ~~~~~^~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:70:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 248 KB Output is correct
2 Correct 8 ms 248 KB Output is correct
3 Correct 4 ms 380 KB Output is correct
4 Correct 4 ms 320 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 9 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 9 ms 248 KB Output is correct
3 Correct 5 ms 320 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 8 ms 248 KB Output is correct
6 Correct 8 ms 248 KB Output is correct
7 Correct 9 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 248 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Correct 4 ms 324 KB Output is correct
5 Correct 10 ms 376 KB Output is correct
6 Correct 8 ms 248 KB Output is correct
7 Correct 11 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 4 ms 248 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 10 ms 376 KB Output is correct
6 Correct 8 ms 376 KB Output is correct
7 Correct 10 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 9 ms 376 KB Output is correct
3 Correct 8 ms 248 KB Output is correct
4 Correct 5 ms 320 KB Output is correct
5 Correct 5 ms 320 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct