제출 #499967

#제출 시각아이디문제언어결과실행 시간메모리
499967Khizri콤보 (IOI18_combo)C++17
30 / 100
67 ms468 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string x="ABXY"; int k=0; bool ask(int l,int r,string ans,int n){ string p=""; for(int i=l;i<=r;i++){ p+=ans; for(int j=1;j<=n-ans.size();j++){ p+=x[i]; } } //cout<<p<<endl; int x=press(p)-ans.size(); if(x>0){ k=x; return true; } return false; } string guess_sequence(int n) { string ans=""; for(int i=0;i<n;i++){ if(i==1){ for(int j=0;j<4;j++){ if(x[j]==ans[0]){ x.erase(x.begin()+j); break; } } } int l=0,r=x.size()-1; while(l<=r){ int m=(l+r)/2; if(ask(l,m,ans,n)){ r=m-1; } else{ l=m+1; } } for(int j=0;j<k;j++){ ans+=x[r+1]; i++; } i--; } //cout<<ans<<endl; return ans; }

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

combo.cpp: In function 'bool ask(int, int, std::string, int)':
combo.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |         for(int j=1;j<=n-ans.size();j++){
      |                     ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...