제출 #1083665

#제출 시각아이디문제언어결과실행 시간메모리
1083665erdemfurkanCombo (IOI18_combo)C++14
97 / 100
27 ms1264 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';
    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';
  }
}

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:18:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:34:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:38:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |       if(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:47:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:57:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
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()) {
      |          ~~~~~~^~~~~~~~~~~~~
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()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:79:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:84:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   84 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:94:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   94 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:108:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  108 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:112:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  112 |       if(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:116:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  116 |       if(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:121:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  121 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:131:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  131 |     while(s.length() != N-1) {
      |           ~~~~~~~~~~~^~~~~~
combo.cpp:146:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  146 |       if(sonuc == s.length()) {
      |          ~~~~~~^~~~~~~~~~~~~
combo.cpp:150:16: 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(sonuc == s.length()+1) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:154:16: 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(sonuc == s.length()+2) {
      |          ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:159:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  159 |     if(s.length() == N) return s;
      |        ~~~~~~~~~~~^~~~
combo.cpp:164:1: warning: control reaches end of non-void function [-Wreturn-type]
  164 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...