Submission #111866

#TimeUsernameProblemLanguageResultExecution timeMemory
111866Eug1enaCombo (IOI18_combo)C++14
100 / 100
49 ms572 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; using lint = long long; char first; string convert(string text){ // text by 'A', 'B', 'C' for(int i = 0; i < text.size(); i++){ if(text[i] == 'A'){ if(first <= 'A'){ text[i] = 'B'; }else{ text[i] = 'A'; } }else if(text[i] == 'B'){ if(first <= 'B'){ text[i] = 'X'; }else{ text[i] = 'B'; } }else if(text[i] == 'C'){ if(first <= 'X'){ text[i] = 'Y'; }else{ text[i] = 'X'; } }else{ assert(0); } } return text; } string guess_sequence(int N){ if(press("AB") >= 1){ if(press("A") == 1){ first = 'A'; }else{ first = 'B'; } }else{ if(press("X") == 1){ first = 'X'; }else{ first = 'Y'; } } int now = 1; string ans(1, first); while(now + 1 < N){ int query = press(ans + convert("AA") + ans + convert("AB") + ans + convert("BA")); if(query == now + 2){ int query2 = press(ans + convert("AA")); if(query2 == now + 2){ ans += convert("AA"); }else if(query2 == now + 1){ ans += convert("AB"); }else if(query2 == now){ ans += convert("BA"); }else{ assert(0); } now += 2; }else if(query == now + 1){ int query2 = press(ans + convert("BB")); if(query2 == now + 2){ ans += convert("BB"); }else if(query2 == now + 1){ ans += convert("BC"); }else if(query2 == now){ ans += convert("AC"); }else{ assert(0); } now += 2; }else if(query == now){ ans += convert("C"); now++; }else{ assert(0); } } if(now + 1 == N){ if(press(ans + convert("A")) == N){ return ans + convert("A"); }else if(press(ans + convert("B")) == N){ return ans + convert("B"); }else{ return ans + convert("C"); } }else{ return ans; } }

Compilation message (stderr)

combo.cpp: In function 'std::string convert(std::string)':
combo.cpp:9:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i = 0; i < text.size(); i++){
      |                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...