제출 #309708

#제출 시각아이디문제언어결과실행 시간메모리
309708lukameladzeCombo (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
# include <combo.h>
std::string guess_sequence(int N)
 {
 	std::string pref;
  std::string p="AB";
  int c=press(p);
  if (c)
  {
     p="A";
     c=press(p);
  	if (c)
  	pref="A";
  	else pref="B";
  }
  else
  {
     p="X";
  	c=press(p);
  	if (c)
  	pref="X";
  	else pref="Y";
  }
  
  if (pref=="A")
  {       while (pref.size()<N-1)
       {
       	cout<<pref<<" 1"<<endl;
          p=pref+"B"+pref+"XY"+pref+"XB"+pref+"XX";
          c=press(p);
          if(c==pref.size()+1)
          {
	          pref+="B";
          }
          else
          if (c==pref.size()+2)
          {
               pref+="X";
          }	
          else pref+="Y";
        }
        c=press(pref+"X");
        if (c==N)
        pref+="X";
        else
        {
        c=press(pref+"Y");
        if (c==N)
        pref+="Y";
        if (pref.size()!=N)
        pref+="B";
	}
     }
     if (pref=="X")
  {
       while (pref.size()<N-1)
       {
          p=pref+"B"+pref+"AY"+pref+"AB"+pref+"AA";
          c=press(p);
          if(c==pref.size()+1)
          {
	          pref+="B";
          }
          else
          if (c==pref.size()+2)
          {
               pref+="A";
          }	
          else pref+="Y";
        }
        c=press(pref+"A");
        if (c==N)
        pref+="A";
        else
        {
        c=press(pref+"Y");
        if (c==N)
        pref+="Y";
        if (pref.size()!=N)
        pref+="B";
	}
     }
     if (pref=="B")
  {
       while (pref.size()<N-1)
       {
          p=pref+"A"+pref+"XY"+pref+"XA"+pref+"XX";
          c=press(p);
          if(c==pref.size()+1)
          {
	          pref+="A";
          }
          else
          if (c==pref.size()+2)
          {
               pref+="X";
          }	
          else pref+="Y";
        }
        c=press(pref+"X");
        if (c==N)
        pref+="X";
        else
        {
	
	c=press(pref+"Y");
        if (c==N)
        pref+="Y";
        if (pref.size()!=N)
        pref+="A";
	}
     }
     if (pref=="Y")
  {
       while (pref.size()<N-1)
       {
          p=pref+"B"+pref+"XA"+pref+"XB"+pref+"XX";
          c=press(p);
          if(c==pref.size()+1)
          {
	          pref+="B";
          }
          else
          if (c==pref.size()+2)
          {
               pref+="X";
          }	
          else pref+="A";
        }
        c=press(pref+"X");
        if (c==N)
        pref+="X";
        {
        c=press(pref+"A");
        if (c==N)
        pref+="A";
        if (pref.size()!=N)
        pref+="B";
	}
     }
     return pref;
  }  

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:29: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |   {       while (pref.size()<N-1)
      |                  ~~~~~~~~~~~^~~~
combo.cpp:27:9: error: 'cout' was not declared in this scope
   27 |         cout<<pref<<" 1"<<endl;
      |         ^~~~
combo.cpp:27:27: error: 'endl' was not declared in this scope
   27 |         cout<<pref<<" 1"<<endl;
      |                           ^~~~
combo.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
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 (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:49:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:55:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   55 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:59:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:64:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:78:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   78 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:84:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   84 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:88:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:93:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:108:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  108 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:114:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  114 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:118:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:123:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  123 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:136:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  136 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~