제출 #689945

#제출 시각아이디문제언어결과실행 시간메모리
689945Jovan26Combo (IOI18_combo)C++14
5 / 100
1 ms256 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
  string s = "";
  char slova[4] = {'A', 'B', 'X', 'Y'};
  for(int i=0;i<3;i++){
    string temp = "";
    temp.push_back(slova[i]);
    int a = press(temp);
    if(a==1){
        s.push_back(slova[i]);
        break;
    }
  }
  if(s=="") s.push_back('Y');
  if(s[0]=='A'){
  for(int i=1;i<N-1;i++){
    string temp = s;
    temp.push_back('X');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('Y');
    temp.push_back('X');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('Y');
    temp.push_back('B');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('Y');
    temp.push_back('Y');

    int a = press(temp);
    int x = s.size();
    if(a==x) s.push_back('B');
    else if(a==x+1) s.push_back('X');
    else s.push_back('Y');
  }
  int a = press(s+"B");
  if(a==s.size()+1) s.push_back('B');
  else{
    int b = press(s+"X");
    if(b==s.size()+1) s.push_back('X');
    else s.push_back('Y');
  }
  }



  else if(s[0]=='B'){
  for(int i=1;i<N-1;i++){
    string temp = s;
    temp.push_back('X');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('Y');
    temp.push_back('X');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('Y');
    temp.push_back('A');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('Y');
    temp.push_back('Y');

    int a = press(temp);
    int x = s.size();
    if(a==x) s.push_back('A');
    else if(a==x+1) s.push_back('X');
    else s.push_back('Y');
  }
  int a = press(s+"A");
  if(a==s.size()+1) s.push_back('A');
  else{
    int b = press(s+"X");
    if(b==s.size()+1) s.push_back('X');
    else s.push_back('Y');
  }
  }




  else if(s[0]=='X'){
  for(int i=1;i<N-1;i++){
    string temp = s;
    temp.push_back('A');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('Y');
    temp.push_back('B');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('Y');
    temp.push_back('A');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('Y');
    temp.push_back('Y');

    int a = press(temp);
    int x = s.size();
    if(a==x) s.push_back('B');
    else if(a==x+1) s.push_back('A');
    else s.push_back('Y');
  }
  int a = press(s+"A");
  if(a==s.size()+1) s.push_back('A');
  else{
    int b = press(s+"B");
    if(b==s.size()+1) s.push_back('B');
    else s.push_back('Y');
  }
  }





  else if(s[0]=='Y'){
  for(int i=1;i<N-1;i++){
    string temp = s;
    temp.push_back('X');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('A');
    temp.push_back('X');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('A');
    temp.push_back('B');

    for(int j=0;j<s.size();j++) temp.push_back(s[j]);
    temp.push_back('A');
    temp.push_back('A');

    int a = press(temp);
    int x = s.size();
    if(a==x) s.push_back('B');
    else if(a==x+1) s.push_back('X');
    else s.push_back('A');
  }
  int a = press(s+"A");
  if(a==s.size()+1) s.push_back('A');
  else{
    int b = press(s+"X");
    if(b==s.size()+1) s.push_back('X');
    else s.push_back('B');
  }
  }

  return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:41:7: 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(a==s.size()+1) s.push_back('B');
      |      ~^~~~~~~~~~~~
combo.cpp:44:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     if(b==s.size()+1) s.push_back('X');
      |        ~^~~~~~~~~~~~
combo.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:64:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:75:7: 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(a==s.size()+1) s.push_back('A');
      |      ~^~~~~~~~~~~~
combo.cpp:78:9: 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(b==s.size()+1) s.push_back('X');
      |        ~^~~~~~~~~~~~
combo.cpp:91:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:95:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:99:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:110:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  110 |   if(a==s.size()+1) s.push_back('A');
      |      ~^~~~~~~~~~~~
combo.cpp:113:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  113 |     if(b==s.size()+1) s.push_back('B');
      |        ~^~~~~~~~~~~~
combo.cpp:127:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  127 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:131:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  131 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:135:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  135 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:146:7: 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(a==s.size()+1) s.push_back('A');
      |      ~^~~~~~~~~~~~
combo.cpp:149:9: 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(b==s.size()+1) s.push_back('X');
      |        ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...