Submission #636548

#TimeUsernameProblemLanguageResultExecution timeMemory
636548SonCombo (IOI18_combo)C++14
0 / 100
29 ms456 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 = ""; if ( N > 2 ){ int ab = press("AXYAXXA"); if ( ab == 5 ){ ans = "YAXXA"; } else if ( ab == 4 ){ ans = "YAXX"; } else if ( ab == 3 ){ ab = press("AXX"); if ( ab == 3 ){ ans = "AXX"; } else if ( ab == 2 ){ ans = "AXY"; } else if ( ab == 1 ){ ans = "XYA"; } else { ans = "YAX"; } } else if ( ab == 2 ){ ab = press("XAA"); if ( ab == 3 ){ ans = "XAA"; } else if ( ab == 2 ){ ans = "XAY"; } else if ( ab == 1 ){ ans = "XYY"; } else { ans = "YAA"; } } else if ( ab == 1 ){ ab = press("AYYA"); if ( ab == 3 ){ ans = "AYY"; } else if ( ab == 2 ){ ans = "AYX"; } else if ( ab == 1 ){ ans = "YX"; } else { ans = "YX"; } } else { ans = "B"; } } else { 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 < V.size(); i++ ){ if ( V[i] == ans[0] ){ ch = i; } else { W.push_back(V[i]); } } while ( (int)(ans.size()) < N ){ int prevN = (int)(ans.size()); if ( N - prevN == 1 ){ string t = ans + W[0]; if ( press(t) == prevN + 1 ){ ans += W[0]; } else { t = ans + W[1]; if ( press(t) == prevN + 1 ){ ans += W[1]; } else { ans += W[2]; } } } else { string t = ans + W[0]; t += ans + W[1] + W[0]; t += ans + W[1] + W[1]; t += ans + W[1] + W[2]; int pt = press(t); if ( pt == prevN ){ ans += W[2]; } else if ( pt == prevN + 1 ){ ans += W[0]; } else { ans += W[1]; } } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:81:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for ( int i = 0; i < V.size(); i++ ){
      |                      ~~^~~~~~~~~~
combo.cpp:79:9: warning: variable 'ch' set but not used [-Wunused-but-set-variable]
   79 |     int ch;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...