제출 #866706

#제출 시각아이디문제언어결과실행 시간메모리
866706MercubytheFirst콤보 (IOI18_combo)C++14
100 / 100
16 ms1740 KiB
#include<bits/stdc++.h> #include"combo.h" using namespace std; // int press(string s){ // return 1; // } string guess_sequence(int n){ vector<char>buttons = {'A','B','X','Y'}; char starting_char = '0'; if(press("AB")){ if(press("A")) starting_char = 'A'; else starting_char = 'B'; } else{ if(press("X")) starting_char = 'X'; else starting_char = 'Y'; } string ans{starting_char}; buttons.erase(find(buttons.begin(), buttons.end(), starting_char)); if(ans.length() == n) return ans; // s + B + s + XY + s + XB + s + XX -> if starting_char == A for(int i = 1; i < n - 1; ++i){ int current_coins = press(ans + string{buttons[0]} + ans + string{buttons[1],buttons[0]} + ans + string{buttons[1], buttons[1]} + ans + string{buttons[1], buttons[2]}); if(current_coins == i) ans.push_back(buttons[2]); else if(current_coins == i + 1) ans.push_back(buttons[0]); else if(current_coins == i + 2) ans.push_back(buttons[1]); } if(press(ans + string{buttons[0]} + ans + string{buttons[1]}) == n){ if(press(ans + string{buttons[0]}) == n) ans.push_back(buttons[0]); else ans.push_back(buttons[1]); } else{ ans.push_back(buttons[2]); } return ans; }

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

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