제출 #239409

#제출 시각아이디문제언어결과실행 시간메모리
239409ctziapo콤보 (IOI18_combo)C++14
100 / 100
40 ms684 KiB
#include "combo.h" using namespace std; std::string guess_sequence(int N) { std::string p = ""; string s; string s1; string s2; string s3; int t=press("AB"); if(t!=0){ int t2=press("A"); if(t2==1){ s="A"; s1="B"; s2="X"; s3="Y"; } else{ s="B"; s1="A"; s2="X"; s3="Y"; } } else { int t2=press("X"); if(t2==1){ s="X"; s1="B"; s2="Y"; s3="A"; } else{ s="Y"; s1="B"; s2="X"; s3="A"; } } // cout<<"first letter is "<<s<<endl; int cou=1; string ans; ans=s; for(int i=1;i<N-1;i++){ // cout<<ans<<" "<<ans.size()<<endl; string f; f=ans + s1 + ans + s2 + s1 + ans + s2 + s2 + ans + s2 + s3; int t=press(f); // cout<<f<<" "<<t<<" "<<f.size()<<"/"<<N<<endl; // cout<<endl; if(t==cou+1){ cou++; ans=ans+s1; } else if(t==cou+2){ cou++; ans=ans + s2; } else { cou++; ans=ans + s3; } } // cout<<"answeeer "<<ans<<endl; if(ans.size()!=N) if(press(ans + s1)==N){ ans = ans + s1; } else if(press(ans + s2)==N){ ans = ans + s2; } else ans = ans + s3; return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:75:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   75 |   if(ans.size()!=N)
      |      ~~~~~~~~~~^~~
combo.cpp:75:5: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   75 |   if(ans.size()!=N)
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...