Submission #108505

#TimeUsernameProblemLanguageResultExecution timeMemory
108505abilCombo (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include <bits/stdc++.h> #include "combo.h" #define mk make_pair #define sc second #define fr first #define pb push_back #define all(s) s.begin(), s.end() #define sz(s) ( (int)s.size() ) #define Scan(a) scanf ("%I64d", &a) #define scan(a) scanf ("%d", &a) using namespace std; const long long INF = (int)1e18 + 7; const int N = (int)1e5 + 12; const int mod = 1000000007; string guess_sequence(int N){ string s = "", s1 = "AB"; int cur = press(s1); if(cur == 2){ s = "A"; } else if(cur == 1){ cur = press("A"); if(cur == 1){ s = "A"; } else{ s = "B"; } } else{ s1 = "XY"; int cur = press(s1); if(cur == 2){ s = "X"; } else if(cur == 1){ cur = press("X"); if(cur == 1){ s = "X"; } else{ s = "Y"; } } } char ch = s[0]; if(s.size() == N){ return s; } if(ch == 'A'){ while(s.size() < N){ string s1 = s; s1.pb('B'); s1.pb('X'); s1 = s1 + s; s1.pb('B'); s1.pb('Y'); s1 = s1 + s; s1.pb('B'); s1.pb('B'); s1 = s1 + s; s1.pb('Y'); cur = press(s1); if(cur == s.size()){ s.pb('X'); } else if(cur == s.size() + 1){ s.pb('Y'); } else{ s.pb('B'); } } return s; } if(ch == 'B'){ while(s.size() < N){ string s1 = s; s1.pb('A'); s1.pb('X'); s1 = s1 + s; s1.pb('A'); s1.pb('Y'); s1 = s1 + s; s1.pb('A'); s1.pb('A'); s1 = s1 + s; s1.pb('Y'); cur = press(s1); if(cur == s.size()){ s.pb('X'); } else if(cur == s.size() + 1){ s.pb('Y'); } else{ s.pb('A'); } } return s; } if(ch == 'X'){ while(s.size() < N){ string s1 = s; s1.pb('B'); s1.pb('A'); s1 = s1 + s; s1.pb('B'); s1.pb('Y'); s1 = s1 + s; s1.pb('B'); s1.pb('B'); s1 = s1 + s; s1.pb('Y'); cur = press(s1); if(cur == s.size()){ s.pb('A'); } else if(cur == s.size() + 1){ s.pb('Y'); } else{ s.pb('B'); } } return s; } if(ch == 'Y'){ while(s.size() < N){ string s1 = s; s1.pb('B'); s1.pb('X'); s1 = s1 + s; s1.pb('B'); s1.pb('A'); s1 = s1 + s; s1.pb('B'); s1.pb('B'); s1 = s1 + s; s1.pb('A'); cur = press(s1); if(cur == s.size()){ s.pb('X'); } else if(cur == s.size() + 1){ s.pb('A'); } else{ s.pb('B'); } } return s; } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:52:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |       if(s.size() == N){
      |          ~~~~~~~~~^~~~
combo.cpp:56:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |             while(s.size() < N){
      |                   ~~~~~~~~~^~~
combo.cpp:69:26: 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(cur == s.size()){
      |                      ~~~~^~~~~~~~~~~
combo.cpp:73:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |                   if(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:83:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   83 |             while(s.size() < N){
      |                   ~~~~~~~~~^~~
combo.cpp:96:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |                   if(cur == s.size()){
      |                      ~~~~^~~~~~~~~~~
combo.cpp:100:26: 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(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:110:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  110 |             while(s.size() < N){
      |                   ~~~~~~~~~^~~
combo.cpp:123:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  123 |                   if(cur == s.size()){
      |                      ~~~~^~~~~~~~~~~
combo.cpp:127:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  127 |                   if(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:137:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  137 |             while(s.size() < N){
      |                   ~~~~~~~~~^~~
combo.cpp:150:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  150 |                   if(cur == s.size()){
      |                      ~~~~^~~~~~~~~~~
combo.cpp:154:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  154 |                   if(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:19:27: warning: control reaches end of non-void function [-Wreturn-type]
   19 |       string s = "", s1 = "AB";
      |                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...