제출 #309709

#제출 시각아이디문제언어결과실행 시간메모리
309709lukameladze콤보 (IOI18_combo)C++14
0 / 100
1 ms200 KiB
# include <combo.h>	
# include <bits/stdc++.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:26:29: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |   {       while (pref.size()<N-1)
      |                  ~~~~~~~~~~~^~~~
combo.cpp:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:50:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:56:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:60:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:65:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:79:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:85:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   85 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:89:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:94:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:109:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  109 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:115:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  115 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:119:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  119 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:124:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  124 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:137:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  137 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...