Submission #276099

#TimeUsernameProblemLanguageResultExecution timeMemory
276099Bill_00Combo (IOI18_combo)C++14
100 / 100
39 ms604 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,l; l.push_back('A'); l.push_back('B'); l.push_back('X'); l.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; if(n==1) return ans; for(int i=0;i<4;i++){ if(l[i]!=k) a.push_back(l[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()){ g=ans+'X'; p=press(g); 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:35:7: 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(p==ans.size()){
      |      ~^~~~~~~~~~~~
combo.cpp:39:8: 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(p==ans.size()+1){
      |       ~^~~~~~~~~~~~~~
combo.cpp:47:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |  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...