제출 #313322

#제출 시각아이디문제언어결과실행 시간메모리
313322noob_c0de콤보 (IOI18_combo)C++17
100 / 100
49 ms576 KiB
// author shenron #include<bits/stdc++.h> #include "combo.h" using namespace std; string ans; /*int press(string p) { cout<<p<<"\n"; int d; cin>>d; return(d); }*/ string guess_sequence(int n) { string init; // first character int q1=press("AB"); if (q1>=1) { int q2=press("A"); if (q2>=1) { ans+='A'; init="BXY"; } else { ans+='B'; init="AXY"; } } else { int q2=press("X"); if (q2>=1) { ans+='X'; init="ABY"; } else { ans+='Y'; init="ABX"; } } // cout<<ans<<"\n"; // n-2 next character for (int i=1;i<n-1;i++) { string ask=ans+init[0]; for (int ch=0;ch<3;ch++) { ask+=ans; ask+=init[1]; ask+=init[ch]; } int res=press(ask); if (res==ans.size()) ans+=init[2]; else if(res==ans.size()+1) ans+=init[0]; else ans+=init[1]; // cout<<ans<<"\n"; } // last character if (ans.size()==n) return(ans); string ask; for (int i=0;i<2;i++) { ask+=ans; ask+=init[i]; } int res=press(ask); if (res==ans.size()) ans+=init[2]; else { ask=ans+init[0]; res=press(ask); if (res==ans.size()) ans+=init[1]; else ans+=init[0]; } return(ans); } /*int main() { int m; cin>>m; cout<<guess_sequence(m); return 0; }*/

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:58:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         if (res==ans.size()) ans+=init[2];
      |             ~~~^~~~~~~~~~~~
combo.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         else if(res==ans.size()+1) ans+=init[0];
      |                 ~~~^~~~~~~~~~~~~~
combo.cpp:64:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   64 |     if (ans.size()==n) return(ans);
      |         ~~~~~~~~~~^~~
combo.cpp:72:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     if (res==ans.size()) ans+=init[2];
      |         ~~~^~~~~~~~~~~~
combo.cpp:77:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |         if (res==ans.size()) ans+=init[1];
      |             ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...