제출 #689948

#제출 시각아이디문제언어결과실행 시간메모리
689948Jovan26콤보 (IOI18_combo)C++14
97 / 100
63 ms680 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(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:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:42:7: 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(a==s.size()+1) s.push_back('B');
      |      ~^~~~~~~~~~~~
combo.cpp:45:9: 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(b==s.size()+1) s.push_back('X');
      |        ~^~~~~~~~~~~~
combo.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:65:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:76:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |   if(a==s.size()+1) s.push_back('A');
      |      ~^~~~~~~~~~~~
combo.cpp:79:9: 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(b==s.size()+1) s.push_back('X');
      |        ~^~~~~~~~~~~~
combo.cpp:92:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:96:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:100:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:111:7: 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(a==s.size()+1) s.push_back('A');
      |      ~^~~~~~~~~~~~
combo.cpp:114:9: 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(b==s.size()+1) s.push_back('B');
      |        ~^~~~~~~~~~~~
combo.cpp:128:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  128 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:132:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  132 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:136:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  136 |     for(int j=0;j<s.size();j++) temp.push_back(s[j]);
      |                 ~^~~~~~~~~
combo.cpp:147:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  147 |   if(a==s.size()+1) s.push_back('A');
      |      ~^~~~~~~~~~~~
combo.cpp:150:9: 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(b==s.size()+1) s.push_back('X');
      |        ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...