제출 #434447

#제출 시각아이디문제언어결과실행 시간메모리
434447chirathnirodha콤보 (IOI18_combo)C++17
100 / 100
48 ms692 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; #define MP make_pair #define PB push_back #define F first #define S second string guess_sequence(int N) { int x;string check; x=press("AB"); string ans; if(x>0){ if(x==1){ x=press("A"); if(x==1)ans.PB('A'); else ans.PB('B'); } else ans.PB('A'); } else{ x=press("X"); if(x==1)ans.PB('X'); else ans.PB('Y'); } if(ans.size()==N)return ans; vector<char> rem; rem.PB('A');rem.PB('B');rem.PB('X');rem.PB('Y'); for(int i=0;i<4;i++)if(rem[i]==ans[0]){rem.erase(rem.begin()+i);break;} for(int i=1;i<N-1;i++){ check=(ans+rem[0]) + (ans+rem[1]+rem[0]) + (ans+rem[1]+rem[1]) + (ans+rem[1]+rem[2]); x=press(check)-ans.size(); if(x==0)ans.PB(rem[2]); else if(x==1)ans.PB(rem[0]); else ans.PB(rem[1]); } check=ans+rem[0];x=press(check)-ans.size(); if(x==1)ans.PB(rem[0]); else { check=ans+rem[1];x=press(check)-ans.size(); if(x==1)ans.PB(rem[1]); else ans.PB(rem[2]); } return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |   if(ans.size()==N)return ans;
      |      ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...