Submission #817718

#TimeUsernameProblemLanguageResultExecution timeMemory
817718n3rm1nCombo (IOI18_combo)C++17
30 / 100
23 ms624 KiB
#include<bits/stdc++.h> #include "combo.h" #define endl '\n' using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } string guess_sequence(int N) { string p = "A"; char start; if(press(p) != 0)start = 'A'; else { p = "B"; if(press(p) != 0)start = 'B'; else { p = "X"; if(press(p) != 0)start = 'X'; else { p = "Y"; if(press(p) != 0)start = 'Y'; } } } char free0, free1, free2; if(start == 'A') { free0 = 'B'; free1 = 'X'; free2 = 'Y'; } else if(start == 'B') { free0 = 'A'; free1 = 'X'; free2 = 'Y'; } else if(start == 'X') { free0 = 'A'; free1 = 'B'; free2 = 'Y'; } else { free0 = 'A'; free1 = 'B'; free2 = 'X'; } string certain = ""; certain += start; string try0, try1, try2; string combo = ""; int i = 1; while(i < N && i + 1 < N) { try0 = certain + free0; try0 = try0 + free0; try1 = certain + free1; try1 = try1 + free1; combo = try0 + try1; int result = press(combo), result0; if(result == certain.size() + 2) { if(press(try0) == certain.size() + 2) certain = try0; else certain = try1; } else if(result == certain.size() + 1) { try2 = certain + free0; try2 = try2 + free2; result0 = press(try2); if(result0 == certain.size() + 1) { certain = certain + free0; certain = certain + free1; } else if(result0 == certain.size() + 2) { certain = try2; } else certain = certain + free1; } else certain = certain + free2; i = certain.size(); } ///cout << certain << endl; if(certain.size() < N) { try0 = certain + free0; if(press(try0) == try0.size()) { certain = try0; return certain; } try0 = certain + free1; if(press(try0) == try0.size()) { certain = try0; return certain; } certain = certain + free2; } return certain; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:70:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         if(result == certain.size() + 2)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:72:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |             if(press(try0) == certain.size() + 2)
      |                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:76:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         else if(result == certain.size() + 1)
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:81:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |             if(result0 == certain.size() + 1)
      |                ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:86:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |             else if(result0 == certain.size() + 2)
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:96:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   96 |     if(certain.size() < N)
      |        ~~~~~~~~~~~~~~~^~~
combo.cpp:99:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |         if(press(try0) == try0.size())
      |            ~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:105:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |         if(press(try0) == try0.size())
      |            ~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:33:5: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |     if(start == 'A')
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...