Submission #554190

#TimeUsernameProblemLanguageResultExecution timeMemory
554190morasha3Combo (IOI18_combo)C++17
100 / 100
24 ms612 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string p = "AB"; int c=press(p); string ans; if(c==2) { ans+='A'; } else if(c==1) { p='A'; c=press(p); if(c) ans+='A'; else ans+='B'; } else { p='X'; c=press(p); if(c) ans+='X'; else ans+='Y'; } if(N==1)return ans; for(int i=1;i<N-1;i++) { if(ans[0]=='A') { string temp=ans; temp+='B'; temp+=ans; temp+="XB"; temp+=ans; temp+="XY"; temp+=ans; temp+="XX"; c=press(temp); if(c==1+ans.size()) { ans+='B'; } else if(c==2+ans.size()) { ans+='X'; } else ans+='Y'; } else if(ans[0]=='B') { string temp=ans; temp+='A'; temp+=ans; temp+="XA"; temp+=ans; temp+="XY"; temp+=ans; temp+="XX"; c=press(temp); if(c==1+ans.size()) { ans+='A'; } else if(c==2+ans.size()) { ans+='X'; } else ans+='Y'; } else if(ans[0]=='X') { string temp=ans; temp+='B'; temp+=ans; temp+="AB"; temp+=ans; temp+="AY"; temp+=ans; temp+="AA"; c=press(temp); if(c==1+ans.size()) { ans+='B'; } else if(c==2+ans.size()) { ans+='A'; } else ans+='Y'; } else { string temp=ans; temp+='B'; temp+=ans; temp+="XB"; temp+=ans; temp+="XA"; temp+=ans; temp+="XX"; c=press(temp); if(c==1+ans.size()) { ans+='B'; } else if(c==2+ans.size()) { ans+='X'; } else ans+='A'; } } string temp=ans; if(ans[0]=='A') { temp+='B'; c=press(temp); if(c==N) ans+='B'; else { temp[temp.size()-1]='X'; c=press(temp); if(c==N) ans+='X'; else ans+='Y'; } } else if(ans[0]=='B') { temp+='A'; c=press(temp); if(c==N) ans+='A'; else { temp[temp.size()-1]='X'; c=press(temp); if(c==N) ans+='X'; else ans+='Y'; } } else if(ans[0]=='X') { temp+='B'; c=press(temp); if(c==N) ans+='B'; else { temp[temp.size()-1]='A'; c=press(temp); if(c==N) ans+='A'; else ans+='Y'; } } else { temp+='B'; c=press(temp); if(c==N) ans+='B'; else { temp[temp.size()-1]='X'; c=press(temp); if(c==N) ans+='X'; else ans+='A'; } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if(c==1+ans.size())
      |                ~^~~~~~~~~~~~~~
combo.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             else if(c==2+ans.size())
      |                     ~^~~~~~~~~~~~~~
combo.cpp:63:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             if(c==1+ans.size())
      |                ~^~~~~~~~~~~~~~
combo.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             else if(c==2+ans.size())
      |                     ~^~~~~~~~~~~~~~
combo.cpp:84:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |             if(c==1+ans.size())
      |                ~^~~~~~~~~~~~~~
combo.cpp:88:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |             else if(c==2+ans.size())
      |                     ~^~~~~~~~~~~~~~
combo.cpp:105:17: 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(c==1+ans.size())
      |                ~^~~~~~~~~~~~~~
combo.cpp:109:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  109 |             else if(c==2+ans.size())
      |                     ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...