제출 #153352

#제출 시각아이디문제언어결과실행 시간메모리
153352Ruxandra985콤보 (IOI18_combo)C++14
5 / 100
3 ms1444 KiB
#include <cstdio> #include <cstring> #include "combo.h" using namespace std; char next (char ch){ if (ch == 'A' || ch == 'X') return ch + 1; if (ch == 'B') return 'X'; return 'A'; } string guess_sequence (int n){ int i,j; char curr,fst,scd,thd; string ask,sol; ask.clear(); ask.push_back('A'); ask.push_back('B'); if (press(ask)){ /// e A sau B ask.clear(); ask.push_back('A'); if (press(ask)) curr = 'A'; else curr = 'B'; } else { /// e X sau Y ask.clear(); ask.push_back('X'); if (press(ask)) curr = 'X'; else curr = 'Y'; } /// 2 interogari /// curr e primul caracter sol.clear(); sol.push_back(curr); fst = next(curr); scd = next(fst); thd = next(scd); for (i=2;i<n;i++){ ask.clear(); for (j=0;j<sol.size();j++){ ask.push_back(sol[j]); } ask.push_back(fst); ask.push_back(fst); for (j=0;j<sol.size();j++){ ask.push_back(sol[j]); } ask.push_back(fst); ask.push_back(scd); for (j=0;j<sol.size();j++){ ask.push_back(sol[j]); } ask.push_back(fst); ask.push_back(thd); for (j=0;j<sol.size();j++){ ask.push_back(sol[j]); } ask.push_back(scd); int x = press(ask) - (i-1); if (x == 2) sol.push_back(fst); else if (x == 1) sol.push_back(scd); else sol.push_back(thd); } /// n - 2 interogari /// total : n interogari /// acum pt ultimul caracter ask.clear(); for (j=0;j<sol.size();j++){ ask.push_back(sol[j]); } ask.push_back('A'); for (j=0;j<sol.size();j++){ ask.push_back(sol[j]); } ask.push_back('B'); if (press(ask) == n){ /// e A sau B ask.clear(); for (j=0;j<sol.size();j++){ ask.push_back(sol[j]); } ask.push_back('A'); if (press(ask)==n) sol.push_back('A'); else sol.push_back('B'); } else { /// e X sau Y ask.clear(); for (j=0;j<sol.size();j++){ ask.push_back(sol[j]); } ask.push_back('X'); if (press(ask)==n) sol.push_back('X'); else sol.push_back('Y'); } return sol; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (j=0;j<sol.size();j++){
      |                  ~^~~~~~~~~~~
combo.cpp:54:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for (j=0;j<sol.size();j++){
      |                  ~^~~~~~~~~~~
combo.cpp:60:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         for (j=0;j<sol.size();j++){
      |                  ~^~~~~~~~~~~
combo.cpp:66:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         for (j=0;j<sol.size();j++){
      |                  ~^~~~~~~~~~~
combo.cpp:83:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for (j=0;j<sol.size();j++){
      |              ~^~~~~~~~~~~
combo.cpp:87:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |     for (j=0;j<sol.size();j++){
      |              ~^~~~~~~~~~~
combo.cpp:94:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |         for (j=0;j<sol.size();j++){
      |                  ~^~~~~~~~~~~
combo.cpp:105:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |         for (j=0;j<sol.size();j++){
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...