제출 #166532

#제출 시각아이디문제언어결과실행 시간메모리
166532LawlietCarnival (CEOI14_carnival)C++14
100 / 100
11 ms380 KiB
#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]); }

컴파일 시 표준 에러 (stderr) 메시지

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);
  ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...