Submission #108503

#TimeUsernameProblemLanguageResultExecution timeMemory
108503abilCombo (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('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('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('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('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:66:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |                   if(cur == s.size()){
      |                      ~~~~^~~~~~~~~~~
combo.cpp:70:26: 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(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:80:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   80 |             while(s.size() < N){
      |                   ~~~~~~~~~^~~
combo.cpp:90:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |                   if(cur == s.size()){
      |                      ~~~~^~~~~~~~~~~
combo.cpp:94:26: 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(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:104:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  104 |             while(s.size() < N){
      |                   ~~~~~~~~~^~~
combo.cpp:114:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  114 |                   if(cur == s.size()){
      |                      ~~~~^~~~~~~~~~~
combo.cpp:118:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |                   if(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:128:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  128 |             while(s.size() < N){
      |                   ~~~~~~~~~^~~
combo.cpp:138:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  138 |                   if(cur == s.size()){
      |                      ~~~~^~~~~~~~~~~
combo.cpp:142:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  142 |                   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...