Submission #827417

#TimeUsernameProblemLanguageResultExecution timeMemory
827417AlesL0Combo (IOI18_combo)C++17
100 / 100
23 ms560 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N){ vector <char> c = {'A', 'B', 'X', 'Y'}; string S = ""; if (press("AB") > 0){ if (press("A") > 0){ S = "A"; c.erase(c.begin()); } else { S = "B"; c.erase(c.begin()+1); } } else { if (press("X") > 0){ S = "X"; c.erase(c.begin()+2); } else { S = "Y"; c.erase(c.begin()+3); } } //cerr << S << "\n"; if (S.size() == N)return S; for (int i = 1; i < N-1; i++){ string T = S+c[0]+S+c[1]+c[0]+S+c[1]+c[1]+S+c[1]+c[2]; //cerr << T << "\n"; int x = press(T); if (x == S.size())S += c[2]; if (x == S.size()+1)S += c[0]; if (x == S.size()+2)S += c[1]; //cerr << S << "\n"; } string T = S+c[0]+S+c[1]; if (press(T) > S.size()){ T = S+c[0]; if (press(T) > S.size())S += c[0]; else S += c[1]; } else S += c[2]; //cerr << S << "\n"; return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |     if (S.size() == N)return S;
      |         ~~~~~~~~~^~~~
combo.cpp:35:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if (x == S.size())S += c[2];
      |             ~~^~~~~~~~~~~
combo.cpp:36:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         if (x == S.size()+1)S += c[0];
      |             ~~^~~~~~~~~~~~~
combo.cpp:37:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if (x == S.size()+2)S += c[1];
      |             ~~^~~~~~~~~~~~~
combo.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     if (press(T) > S.size()){
      |         ~~~~~~~~~^~~~~~~~~~
combo.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if (press(T) > S.size())S += c[0];
      |             ~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...