Submission #724756

#TimeUsernameProblemLanguageResultExecution timeMemory
724756hyakupCarnival (CEOI14_carnival)C++17
100 / 100
8 ms292 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 160; int v[maxn]; int cont; vector<int> lista; bool queryInit( int id ){ cout << lista.size() + 1 << " "; for( int x : lista ) cout << x << " "; cout << id << endl; cout.flush(); int resp; cin >> resp; return ( resp == lista.size() + 1 ); } bool query( int l, int r, int id ){ cout << r - l + 2 << " "; for( int i = l; i <= r; i++ ) cout << lista[i] << " "; cout << id << endl; cout.flush(); int resp; cin >> resp; return ( resp != r - l + 2 ); } void solve( int id ){ if( queryInit(id) ){ v[id] = ++cont; lista.push_back(id); return; } int l = 0, r = lista.size() - 1; while( l < r ){ int mid = ( l + r )/2; if( query( l, mid, id ) ) r = mid; else l = mid + 1; } v[id] = v[lista[r]]; } int main(){ int n; cin >> n; for( int i = 1; i <= n; i++ ) solve(i); cout << 0 << " "; for( int i = 1; i <= n; i++ ) cout << v[i] << " "; } // 1 2 1 3 2

Compilation message (stderr)

carnival.cpp: In function 'bool queryInit(int)':
carnival.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     return ( resp == lista.size() + 1 );
      |              ~~~~~^~~~~~~~~~~~~~~~~~~
#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...