Submission #971291

#TimeUsernameProblemLanguageResultExecution timeMemory
971291codefoxCombo (IOI18_combo)C++14
97 / 100
25 ms1908 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; array<char, 4> arr = {'A', 'B', 'Y', 'X'}; char unknown(string s, int j, char f) { string ss; string sol; for (int i = 0; i < j; i++) { ss+=s[i]; } if (f=='A') { sol = ss+'B'; sol += ss+"XX"; sol += ss+"XB"; sol += ss+"XY"; int c = press(sol); if (c==j) return 'Y'; if (c==j+1) return 'B'; else return 'X'; } if (f=='B') { sol = ss+'A'; sol += ss+"XX"; sol += ss+"XA"; sol += ss+"XY"; int c = press(sol); if (c==j) return 'Y'; if (c==j+1) return 'A'; else return 'X'; } if (f=='Y') { sol = ss+'A'; sol += ss+"BX"; sol += ss+"BB"; sol += ss+"BA"; int c = press(sol); if (c==j) return 'X'; if (c==j+1) return 'A'; else return 'B'; } if (f=='X') { sol = ss+'B'; sol += ss+"AA"; sol += ss+"AB"; sol += ss+"AY"; int c = press(sol); if (c==j) return 'Y'; if (c==j+1) return 'B'; else return 'A'; } } string guess_sequence(int N) { char f = 'N'; for (int i = 0; i < 3; i++) { string st = ""; st += arr[i]; if (press(st)) { f = arr[i]; break; } } if (f=='N') f = 'X'; if (N==1) { string s = ""; s+=f; return s; } string s = ""; s += f; for (int i = 1; i < N-1; i++) { s += unknown(s, i, f); } if (f!='A' && press(s+'A')==N) return s+'A'; if (f!='B' && press(s+'B')==N) return s+'B'; if (f =='X') return s+'Y'; if (f=='Y') return s+'X'; if (press(s+'Y')==N) return s+'Y'; else return s+'X'; }

Compilation message (stderr)

combo.cpp: In function 'char unknown(std::string, int, char)':
combo.cpp:10:12: warning: control reaches end of non-void function [-Wreturn-type]
   10 |     string ss;
      |            ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...