제출 #594480

#제출 시각아이디문제언어결과실행 시간메모리
594480yutabi콤보 (IOI18_combo)C++17
5 / 100
1 ms280 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { char start='A'; char buttons[]={'A','B','X'}; string ans=""; 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) { swap(buttons[0],buttons[1]); } if(buttons[1]==start) { swap(buttons[2],buttons[1]); } if(buttons[2]==start) { buttons[2]='Y'; } //cout << start << ' ' << buttons[0] << ' ' << buttons[1] << ' ' << buttons[2] << endl; ans=""; ans+=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+=buttons[2]; } if(res==i+1) { ans+=buttons[1]; } if(res==i+2) { ans+=buttons[0]; } } query=""; for(int i=0;i<ans.size();i++) { query+=ans[i]; } query+=buttons[0]; if(press(query)==N) { ans+=buttons[0]; } else { query=""; for(int i=0;i<ans.size();i++) { query+=ans[i]; } query+=buttons[1]; if(press(query)==N) { ans+=buttons[1]; } else { ans+=buttons[2]; } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:76:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         for(int j=0;j<ans.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:84:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |         for(int j=0;j<ans.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:92:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |         for(int j=0;j<ans.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:100:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |         for(int j=0;j<ans.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:129:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  129 |     for(int i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
combo.cpp:145:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  145 |         for(int i=0;i<ans.size();i++)
      |                     ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...