제출 #309727

#제출 시각아이디문제언어결과실행 시간메모리
309727lukameladze콤보 (IOI18_combo)C++14
100 / 100
41 ms728 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 (N==1) { return pref; } 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) { // cout<<pref<<" 1"<<endl; 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"; } // cout<<pref<<endl; c=press(pref+"X"); if (c==N) pref+="X"; else { 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:30:29: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   {       while (pref.size()<N-1)
      |                  ~~~~~~~~~~~^~~~
combo.cpp:35:15: 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()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:40:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:54:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:60:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:65:15: 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()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:70:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:84:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   84 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:90:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   90 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:94:15: 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()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:99:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:114:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  114 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:120:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  120 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:124:15: 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()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:129:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  129 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:144:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  144 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...