Submission #636403

#TimeUsernameProblemLanguageResultExecution timeMemory
636403SonCombo (IOI18_combo)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence( int N ){ vector < char > V; V.push_back('A'); V.push_back('B'); V.push_back('Y'); V.push_back('X'); string ans = ""; int ab = press("AB"); if ( ab == 2 ){ ans = "AB"; } else if ( ab == 1 ){ ab = press("A"); if ( ab == 1 ) ans = "A"; else ans = "B"; } else { int xy = press("XY"); if ( xy == 2 ){ ans = "XY"; } else if ( xy == 1 ) { xy = press("X"); if ( xy == 1 ) ans = "X"; else ans = "Y"; } else { assert(1==2); } } int ch; vector < char > W; for ( int i = 0; i < 4; i++ ){ if ( V[i] == ans[0] ){ ch = i; } else { W.push_back(V[i]); } } while ( ans.size() < N ){ string t = ans + W[0] + "" + W[1]; int p = press(t); if ( p == ans.size() + 2 ){ ans += W[0] + W[1]; } else if ( p == ans.size() + 1 ){ ans += W[0]; } else if ( p == ans.size() ) { ans += W[2]; } else { assert(1==2); } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:43:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |     while ( ans.size() < N ){
      |             ~~~~~~~~~~~^~~
combo.cpp:46:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         if ( p == ans.size() + 2 ){
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:48:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         } else if ( p == ans.size() + 1 ){
      |                     ~~^~~~~~~~~~~~~~~~~
combo.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         } else if ( p == ans.size() ) {
      |                     ~~^~~~~~~~~~~~~
combo.cpp:34:9: warning: variable 'ch' set but not used [-Wunused-but-set-variable]
   34 |     int ch;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...