Submission #1007147

#TimeUsernameProblemLanguageResultExecution timeMemory
1007147christinelynnCombo (IOI18_combo)C++17
0 / 100
0 ms344 KiB
using namespace std; #include "combo.h" string guess_sequence ( int n ){ string s = ""; string temp = "AB"; int y = press(temp); if ( y == 1 || y == 2 ){ temp = "A"; y = press ( temp ); if ( y == 1 ) s = "A"; else s = "B"; } else{ temp = "X"; y = press ( temp ); if ( y == 1 ) s = "X"; else s = "Y"; } if ( n == 1 ) return s; for ( int i = 1; i <= n - 2; i++ ){ string t1, t2, t3, t4; if ( s[0] == 'A' ){ t1 = s; t1 += 'B'; t2 = s; t2 += "XX"; t3 = s; t3 += "XY"; t4 = s; t4 += "XB"; temp = t1 + t2 + t3 + t4; y = press ( temp ); if ( y == s.length()) s += 'Y'; else if ( y == s.length() + 1) s += 'B'; else s += 'X'; } else if ( s[0] == 'B'){ t1 = s; t1 += 'A'; t2 = s; t2 += "XX"; t3 = s; t3 += "XY"; t4 = s; t4 += "XA"; temp = t1 + t2 + t3 + t4; y = press ( temp ); if ( y == s.length()) s += 'Y'; else if ( y == s.length() + 1) s += 'A'; else s += 'X'; } else if ( s[0] == 'X'){ t1 = s; t1 += 'A'; t2 = s; t2 += "BB"; t3 = s; t3 += "BY"; t4 = s; t4 += "BA"; temp = t1 + t2 + t3 + t4; y = press ( temp ); if ( y == s.length()) s += 'Y'; if ( y == s.length() + 1) s += 'A'; if ( y == s.length() + 2 ) s += 'B'; } else if ( s[0] == 'Y' ){ t1 = s; t1 += 'B'; t2 = s; t2 += "XB"; t3 = s; t3 += "XA"; t4 = s; t4 += "XX"; temp = t1 + t2 + t3 + t4; y = press ( temp ); if ( y == s.length() ) s += 'A'; if ( y == s.length() + 1) s += 'B'; if ( y == s.length() + 2 ) s += 'X'; } } if ( s[0] == 'A' ){ temp = "B"; y = press(temp); if ( y == s.length() + 1) s += 'B'; else{ temp = "X"; y = press ( temp ); if ( y == s.length() + 1) s += 'X'; else s += 'Y'; } } else if ( s[0] == 'B' ){ temp = "A"; y = press ( temp ); if ( y == s.length() + 1) s += 'A'; else{ temp = "X"; y = press ( temp ); if ( y == s.length() + 1) s += 'X'; else s += 'Y'; } } else if ( s[0] == 'X' ){ temp = "A"; y = press ( temp ); if ( y == s.length() + 1) s += 'A'; else{ temp = "B"; y = press ( temp ); if ( y == s.length() + 1) s += 'B'; else s += 'Y'; } } else if ( s[0] == 'Y'){ temp = "A"; y = press ( temp ); if ( y == s.length() + 1) s += 'A'; else{ temp = "B"; y = press ( temp ); if ( y == s.length() + 1) s += 'B'; else s += 'X'; } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             if ( y == s.length()) s += 'Y';
      |                  ~~^~~~~~~~~~~~~
combo.cpp:42:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             else if ( y == s.length() + 1) s += 'B';
      |                       ~~^~~~~~~~~~~~~~~~~
combo.cpp:55:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             if ( y == s.length()) s += 'Y';
      |                  ~~^~~~~~~~~~~~~
combo.cpp:56:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |             else if ( y == s.length() + 1) s += 'A';
      |                       ~~^~~~~~~~~~~~~~~~~
combo.cpp:69:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |             if ( y == s.length()) s +=  'Y';
      |                  ~~^~~~~~~~~~~~~
combo.cpp:70:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             if ( y == s.length() + 1) s += 'A';
      |                  ~~^~~~~~~~~~~~~~~~~
combo.cpp:71:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |             if ( y == s.length() + 2 ) s += 'B';
      |                  ~~^~~~~~~~~~~~~~~~~
combo.cpp:83:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |             if ( y == s.length() ) s += 'A';
      |                  ~~^~~~~~~~~~~~~
combo.cpp:84:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |             if ( y == s.length() + 1)  s += 'B';
      |                  ~~^~~~~~~~~~~~~~~~~
combo.cpp:85:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |             if ( y == s.length() + 2 ) s += 'X';
      |                  ~~^~~~~~~~~~~~~~~~~
combo.cpp:94:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |         if ( y == s.length() + 1) s += 'B';
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:100:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |             if ( y == s.length() + 1) s += 'X';
      |                  ~~^~~~~~~~~~~~~~~~~
combo.cpp:109:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  109 |         if ( y == s.length() + 1) s += 'A';
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:115:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  115 |             if ( y == s.length() + 1) s += 'X';
      |                  ~~^~~~~~~~~~~~~~~~~
combo.cpp:124:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  124 |         if ( y == s.length() + 1) s += 'A';
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:130:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  130 |             if ( y == s.length() + 1) s += 'B';
      |                  ~~^~~~~~~~~~~~~~~~~
combo.cpp:139:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  139 |         if ( y == s.length() + 1) s += 'A';
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:145:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  145 |             if ( y == s.length() + 1) s += 'B';
      |                  ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...