Submission #594482

#TimeUsernameProblemLanguageResultExecution timeMemory
594482yutabiCombo (IOI18_combo)C++14
5 / 100
1 ms208 KiB
#include "combo.h" #include <vector> std::string guess_sequence(int N) { char start='A'; char buttons[]={'A','B','X'}; std::vector <char> ans; std::string query=""; query="AB"; if(press(query)>0) { query="A"; if(press(query)>0) { start='A'; } else { start='B'; } } else { query="X"; if(press(query)>0) { start='X'; } else { start='Y'; } } if(buttons[0]==start) { std::swap(buttons[0],buttons[1]); } if(buttons[1]==start) { std::swap(buttons[2],buttons[1]); } if(buttons[2]==start) { buttons[2]='Y'; } //cout << start << ' ' << buttons[0] << ' ' << buttons[1] << ' ' << buttons[2] << endl; ans.clear(); ans.push_back(start); for(int i=1;i<N-1;i++) { query=""; for(int j=0;j<ans.size();j++) { query+=ans[j]; } query+=buttons[0]; query+=buttons[0]; for(int j=0;j<ans.size();j++) { query+=ans[j]; } query+=buttons[0]; query+=buttons[1]; for(int j=0;j<ans.size();j++) { query+=ans[j]; } query+=buttons[0]; query+=buttons[2]; for(int j=0;j<ans.size();j++) { query+=ans[j]; } query+=buttons[1]; //cout << query << endl; int res=press(query); if(res==i) { ans.push_back(buttons[2]); } if(res==i+1) { ans.push_back(buttons[1]); } if(res==i+2) { ans.push_back(buttons[0]); } } query=""; for(int i=0;i<ans.size();i++) { query+=ans[i]; } query+=buttons[0]; if(press(query)==N) { ans.push_back(buttons[0]); } else { query=""; for(int i=0;i<ans.size();i++) { query+=ans[i]; } query+=buttons[1]; if(press(query)==N) { ans.push_back(buttons[1]); } else { ans.push_back(buttons[2]); } } std::string S=""; for(int i=0;i<ans.size();i++) { S+=ans[i]; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:75:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         for(int j=0;j<ans.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:83:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |         for(int j=0;j<ans.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:91:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |         for(int j=0;j<ans.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:99:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |         for(int j=0;j<ans.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:128:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  128 |     for(int i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
combo.cpp:144:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  144 |         for(int i=0;i<ans.size();i++)
      |                     ~^~~~~~~~~~~
combo.cpp:164:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  164 |     for(int i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...