Submission #111857

#TimeUsernameProblemLanguageResultExecution timeMemory
111857Eug1enaCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#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:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i = 0; i < text.size(); i++){
      |                    ~~^~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:8: error: 'press' was not declared in this scope
   35 |     if(press("AB") >= 1){
      |        ^~~~~
combo.cpp:51:21: error: 'press' was not declared in this scope
   51 |         int query = press(ans + convert("AA") + ans + convert("AB") + ans + convert("BA"));
      |                     ^~~~~
combo.cpp:84:12: error: 'press' was not declared in this scope
   84 |         if(press(ans + convert("A")) == N){
      |            ^~~~~
combo.cpp:49:24: warning: control reaches end of non-void function [-Wreturn-type]
   49 |     string ans(1, first);
      |                        ^