Submission #1084683

#TimeUsernameProblemLanguageResultExecution timeMemory
1084683erdemfurkan콤보 (IOI18_combo)C++14
0 / 100
1 ms388 KiB
#include "combo.h"
using namespace std;
 
string s;
 
int a, b, x, y;

string guess_sequence(int N) {
  if(press("AB")) {
  	if(press("A")) a = 1;
  	else b = 1;
  } else {
  	if(press("x")) x = 1;
  	else y = 1;
  }
  if(a) {
    s += 'A';
    if(N == 1) return s;
    // a b y
    // a'yı yalnız bırak tek stringde p+b ve p+y+b p+y+p p+y+a'yı dene
    while(s.length() != N-1) {
      string tmp = s;
      tmp += 'B';
      string tmp2 = s;
      tmp2 += 'Y';
      tmp2 += 'B';
      tmp2 += s;
      tmp2 += 'Y';
      tmp2 += 'Y';
      tmp2 += s;
      tmp2 += 'Y';
      tmp2 += 'X';
      // 4N-8
      string son = tmp + tmp2;
 
      int sonuc = press(son);
      if(sonuc == s.length()) {
        // son harf a'dır
        s += 'X';
      }
      if(sonuc == s.length()+1) {
        // son harf b'dir
        s += 'B';
      }
      if(sonuc == s.length()+2) {
        // son harf y'dir
        s += 'Y';
      }  
    }
    if(s.length() == N) return s;
    if(press(s+'B')==N) return s+'B';
    else if(press(s+'X')==N) return s+'X';
    else return s+'Y';
  }
  if(b) {
    s += 'B';
    if(N == 1) return s;
    // a b y
    // a'yı yalnız bırak tek stringde p+b ve p+y+b p+y+p p+y+a'yı dene
    while(s.length() != N-1) {
      string tmp = s;
      tmp += 'X';
      string tmp2 = s;
      tmp2 += 'Y';
      tmp2 += 'X';
      tmp2 += s;
      tmp2 += 'Y';
      tmp2 += 'A';
      tmp2 += s;
      tmp2 += 'Y';
      tmp2 += 'Y';
      string son = tmp + tmp2;
      int sonuc = press(son);
      if(sonuc == s.length()) {
        // son harf a'dır
        s += 'A';
      }
      if(sonuc == s.length()+1) {
        // son harf b'dir
        s += 'X';
      }
      if(sonuc == s.length()+2) {
        // son harf y'dir
        s += 'Y';
      }    
    }
    if(s.length() == N) return s;
    if(press(s+'A')==N) return s+'A';
    else if(press(s+'X')==N) return s+'X';
    else return s+'Y';
  }
  if(x) {
    s += 'X';
    if(N == 1) return s;
    // a b y
    // a'yı yalnız bırak tek stringde p+b ve p+y+b p+y+p p+y+a'yı dene
    while(s.length() != N-1) {
      string tmp = s;
      tmp += 'B';
      string tmp2 = s;
      tmp2 += 'Y';
      tmp2 += 'B';
      tmp2 += s;
      tmp2 += 'Y';
      tmp2 += 'Y';
      tmp2 += s;
      tmp2 += 'Y';
      tmp2 += 'A';
      string son = tmp + tmp2;
      int sonuc = press(son);
      if(sonuc == s.length()) {
        // son harf a'dır
        s += 'A';
      }
      if(sonuc == s.length()+1) {
        // son harf b'dir
        s += 'B';
      }
      if(sonuc == s.length()+2) {
        // son harf y'dir
        s += 'Y';
      }    
    }
    if(s.length() == N) return s;
    if(press(s+'A')==N) return s+'A';
    else if(press(s+'B')==N) return s+'B';
    else return s+'Y';
  }
  if (y) {
    s += 'Y';
    if(N == 1) return s;
    // a b y
    // a'yı yalnız bırak tek stringde p+b ve p+y+b p+y+p p+y+a'yı dene
    while(s.length() != N-1) {
      string tmp = s;
      tmp += 'B';
      string tmp2 = s;
      tmp2 += 'X';
      tmp2 += 'B';
      tmp2 += s;
      tmp2 += 'X';
      tmp2 += 'X';
      tmp2 += s;
      tmp2 += 'X';
      tmp2 += 'A';
      string son = tmp + tmp2;
 
      int sonuc = press(son);
      if(sonuc == s.length()) {
        // son harf a'dır
        s += 'A';
      }
      if(sonuc == s.length()+1) {
        // son harf b'dir
        s += 'B';
      }
      if(sonuc == s.length()+2) {
        // son harf y'dir
        s += 'X';
      }    
    }
    if(s.length() == N) return s; 
    if(press(s+'A')==N) return s+'A';
    else if(press(s+'B')==N) return s+'B';
    else return s+'X';
  }
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:21:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:41:16: 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(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:45:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:50:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:60:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:74:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:78:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |       if(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:82:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:87:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   87 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:97:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   97 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:111:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  111 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:115:16: 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(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:119:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  119 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:124:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  124 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:134:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  134 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:149:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  149 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:153:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  153 |       if(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:157:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  157 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:162:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  162 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:167:1: warning: control reaches end of non-void function [-Wreturn-type]
  167 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...