Submission #476849

#TimeUsernameProblemLanguageResultExecution timeMemory
476849Valaki2Combo (IOI18_combo)C++14
0 / 100
0 ms200 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; int n; string ans; vector<char> letters = {'A', 'B', 'X', 'Y'}; void getFirst() { char firstChar; int x = press("AB"); int y = press("AX"); if(x == 0) { if(y == 0) { firstChar = 'Y'; } else { firstChar = 'X'; } } else { if(y == 0) { firstChar = 'B'; } else { firstChar = 'A'; } } ans.push_back(firstChar); auto toErase = letters.begin(); for(auto it = letters.begin(); it != letters.end(); it++) { if(*it == firstChar) { toErase = it; } } letters.erase(toErase); } void getLast() { for(int i = 0; i < 2; i++) { if(press(ans + letters[i]) == n) { ans.push_back(letters[i]); } } if(ans.size() != n) { ans.push_back(letters.back()); } } string guess_sequence(int N) { n = N; getFirst(); if(n == 1) { return ans; } for(int i = 2; i < n; ++i) { int x = press(ans + letters[0] + ans + letters[1] + letters[0] + ans + letters[1] + letters[1] + ans + letters[1] + letters[2]); if(x == i - 1) { ans.push_back(letters[2]); } if(x == i) { ans.push_back(letters[0]); } if(x == i + 1) { ans.push_back(letters[1]); } } getLast(); return ans; }

Compilation message (stderr)

combo.cpp: In function 'void getLast()':
combo.cpp:44:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     if(ans.size() != n) {
      |        ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...