Submission #709806

#TimeUsernameProblemLanguageResultExecution timeMemory
709806CyanmondCombo (IOI18_combo)C++17
5 / 100
1 ms208 KiB
#include "combo.h" #include <bits/stdc++.h> std::string guess_sequence(int N) { char firstC; if (press("AB") >= 1) { if (press("A") == 1) { firstC = 'A'; } else { firstC += 'B'; } } else { if (press("X") == 1) { firstC = 'X'; } else { firstC = 'Y'; } } std::vector<char> cs = {'A', 'B', 'X', 'Y'}; for (int i = 0; i < 4; ++i) { if (cs[i] == firstC) { cs.erase(cs.begin() + i); break; } } std::string answer = ""; answer += firstC; for (int i = 1; i < N - 1; ++i) { std::string x = answer; x += cs[1]; x += answer; x += cs[0]; x += cs[0]; x += answer; x += cs[0]; x += cs[1]; x += answer; x += cs[0]; x += cs[2]; const auto res = press(x); if (res == i) { answer += cs[2]; } else if (res == i + 1) { answer += cs[1]; } else { answer += cs[0]; } } if (press(answer + 'A' + answer + 'B') == N) { if (press(answer + 'A') == N) { answer += 'A'; } else { answer += 'B'; } } else { if (press(answer + 'X') == N) { answer += 'X'; } else { answer += 'Y'; } } return answer; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:10:20: warning: 'firstC' may be used uninitialized in this function [-Wmaybe-uninitialized]
   10 |             firstC += 'B';
      |             ~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...