Submission #276070

#TimeUsernameProblemLanguageResultExecution timeMemory
276070Bill_00Combo (IOI18_combo)C++14
5 / 100
1 ms200 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int n){ int p=press("AB"); char k; vector<char>a; a.push_back('A'); a.push_back('B'); a.push_back('X'); a.push_back('Y'); string ans; if(p==0){ p=press("X"); if(p==0){ k='Y'; } else k='X'; } else{ p=press("A"); if(p==0){ k='B'; } else k='A'; } ans+=k; for(int i=0;i<4;i++){ if(a[i]==k){ a.erase(a.begin()+i); } } for(int i=2;i<n;i++){ string g=ans+a[0]+a[0]+ans+a[0]+a[1]+ans+a[0]+a[2]+ans+a[1]; p=press(g); if(p==ans.size()){ ans+=a[2]; } else{ if(p==ans.size()+1){ ans+=a[1]; } else ans+=a[0]; } } string g=ans+'A'+ans+'B'; p=press(g); if(p==ans.size()){ p=press(ans+'X'); if(p==ans.size()){ return ans+'Y'; } else return ans+'X'; } else{ g=ans+'A'; p=press(g); if(p==ans.size()){ return ans+'B'; } else return ans+'A'; } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:7: 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(p==ans.size()){
      |      ~^~~~~~~~~~~~
combo.cpp:40:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |    if(p==ans.size()+1){
      |       ~^~~~~~~~~~~~~~
combo.cpp:48:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |  if(p==ans.size()){
      |     ~^~~~~~~~~~~~
combo.cpp:50:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   if(p==ans.size()){
      |      ~^~~~~~~~~~~~
combo.cpp:58:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   if(p==ans.size()){
      |      ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...