Submission #549435

#TimeUsernameProblemLanguageResultExecution timeMemory
549435esomerCombo (IOI18_combo)C++17
0 / 100
1 ms208 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string ans = ""; vector<string> pos; int x = press("XY"); if(x == 2) {ans += "XY"; pos = {"Y", "A", "B"};} else if(x == 1){ x = press("X"); if(x) {ans = "X"; pos = {"Y", "A", "B"};} else {ans = "Y"; pos = {"X", "A", "B"};} }else{ x = press("A"); if(x) {ans = "A"; pos = {"Y", "X", "B"};} else {ans = "B"; pos = {"Y", "A", "X"};} } while(ans.size() + 2 <= N){ ans += pos[0]; ans += pos[1]; string ss = ans; ans.pop_back(); ans += pos[0]; ss += ans; ans.pop_back(); ans.pop_back(); ans += pos[1]; ans += pos[1]; ss += ans; x = press(ss); ans.pop_back(); ans.pop_back(); if(x == ans.size() + 2){ ans += pos[0]; ans += pos[0]; x = press(ans); if(x == ans.size() + 1){ ans.pop_back(); ans += pos[1]; }else if(x == ans.size()){ ans.pop_back(); ans.pop_back(); ans += pos[1]; ans += pos[1]; } }else if(x == ans.size() + 1){ ans += pos[1]; ans += pos[2]; x = press(ans); if(x == 1){ ans.pop_back(); ans += pos[0]; }else if(x == 0){ ans.pop_back(); ans.pop_back(); ans += pos[0]; ans += pos[2]; } }else ans += pos[2]; } if(ans.size() == N) return ans; else{ ans += pos[0]; x = press(ans); if(x == N) return ans; else{ ans.pop_back(); ans += pos[1]; x = press(ans); if(x) return ans; else{ ans.pop_back(); ans += pos[2]; return ans; } } } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |   while(ans.size() + 2 <= N){
      |         ~~~~~~~~~~~~~~~^~~~
combo.cpp:35:10: 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 == ans.size() + 2){
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:39:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |       if(x == ans.size() + 1){
      |          ~~^~~~~~~~~~~~~~~~~
combo.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |       }else if(x == ans.size()){
      |                ~~^~~~~~~~~~~~~
combo.cpp:48:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     }else if(x == ans.size() + 1){
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:63:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   63 |   if(ans.size() == N) return ans;
      |      ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...