Submission #1083662

#TimeUsernameProblemLanguageResultExecution timeMemory
1083662erdemfurkanCombo (IOI18_combo)C++14
5 / 100
1 ms344 KiB
#include "combo.h"
using namespace std;

string s="";

string guess_sequence(int N) {

  int a = press("A");
  int b = press("B");
  int x = press("X");
  int y = !(a&b&x);
  if(a) {
    s += 'A';
    // 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';
      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';
    // 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';
    // 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';
    // 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:16:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |       if(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:39:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:44:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:53:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:67:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:71:16: 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(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:75:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:80:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   80 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:89:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   89 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:103:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:107:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  107 |       if(sonuc == s.length()+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()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:116:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  116 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:125:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  125 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:140:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  140 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:144:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  144 |       if(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:148:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  148 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:153:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  153 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:158:1: warning: control reaches end of non-void function [-Wreturn-type]
  158 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...