제출 #75440

#제출 시각아이디문제언어결과실행 시간메모리
75440Vardanyan콤보 (IOI18_combo)C++14
100 / 100
50 ms564 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string ans = ""; vector<string> v; if(press("AB") >= 1){ if(press("A") == 1){ ans+="A"; v.push_back("B"); v.push_back("X"); v.push_back("Y"); } else { ans+="B"; v.push_back("A"); v.push_back("X"); v.push_back("Y"); } } else{ if(press("X") == 1){ ans+="X"; v.push_back("B"); v.push_back("A"); v.push_back("Y"); } else { ans+="Y"; v.push_back("B"); v.push_back("X"); v.push_back("A"); } } while(ans.length()+2<=N){ string p = ans+v[0]+ans+v[1]+v[0]+ans+v[1]+v[1]+ans+v[1]+v[2]; int k = press(p); if(k-ans.length() == 1) ans+=v[0]; else if(k-ans.length() == 2) ans+=v[1]; else if(k-ans.length() == 0) ans+=v[2]; } if(ans.length() == N) return ans; if(press(ans+v[0]) == N) return ans+v[0]; if(press(ans+v[1]) == N) return ans+v[1]; return ans+v[2]; }

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

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