제출 #689951

#제출 시각아이디문제언어결과실행 시간메모리
689951Jovan26콤보 (IOI18_combo)C++14
100 / 100
61 ms700 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'}; string tempp = "AB"; int a = press(tempp); if(a==2) s.push_back('A'); else if(a==1){ int b = press("B"); if(b==1) s.push_back('B'); else s.push_back('A'); } else{ int b = press("X"); if(b==1) s.push_back('X'); else s.push_back('Y'); } if(N==1) return s; 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: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:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:45:7: 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(a==s.size()+1) s.push_back('B');
      |      ~^~~~~~~~~~~~
combo.cpp:48:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     if(b==s.size()+1) s.push_back('X');
      |        ~^~~~~~~~~~~~
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:68:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:79:7: 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(a==s.size()+1) s.push_back('A');
      |      ~^~~~~~~~~~~~
combo.cpp:82:9: 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(b==s.size()+1) s.push_back('X');
      |        ~^~~~~~~~~~~~
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:103:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:114:7: 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(a==s.size()+1) s.push_back('A');
      |      ~^~~~~~~~~~~~
combo.cpp:117:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  117 |     if(b==s.size()+1) s.push_back('B');
      |        ~^~~~~~~~~~~~
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:139:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  139 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:150:7: 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(a==s.size()+1) s.push_back('A');
      |      ~^~~~~~~~~~~~
combo.cpp:153:9: 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(b==s.size()+1) s.push_back('X');
      |        ~^~~~~~~~~~~~
combo.cpp:6:8: warning: unused variable 'slova' [-Wunused-variable]
    6 |   char slova[4] = {'A', 'B', 'X', 'Y'};
      |        ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...