제출 #523437

#제출 시각아이디문제언어결과실행 시간메모리
523437dron_rp콤보 (IOI18_combo)C++14
30 / 100
47 ms320 KiB
#include "combo.h" #include <set> #include <iostream> using namespace std; string guess_sequence(int N) { string S = ""; set<char> a = {'A', 'B', 'X', 'Y'}; string p = ""; for (auto& c : a){ p = ""; p += c; int coins = press(p); if (coins == 1){ S += c; a.erase(c); break; } } //cout << S << "\n"; while ((int) S.size() < N){ int idx = 1; for (auto& c : a){ /* if (idx >= 3) break; p = S; p += c; int coins = press(p); if (coins == (int) S.size()+1){ S += c; break; } idx++; */ p = S; for (int i = 0; i<N-S.size(); i++){ p += c; } int coins = press(p); p = ""; if (coins > S.size()){ for (int i = 0; i<coins-S.size(); i++){ p += c; } S += p; break; } } //cout << idx << "\n"; //if (idx >= 3) S += *prev(a.end()); //cout << S << "\n"; } return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             for (int i = 0; i<N-S.size(); i++){
      |                             ~^~~~~~~~~~~
combo.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if (coins > S.size()){
      |                 ~~~~~~^~~~~~~~~~
combo.cpp:43:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |                 for (int i = 0; i<coins-S.size(); i++){
      |                                 ~^~~~~~~~~~~~~~~
combo.cpp:23:13: warning: unused variable 'idx' [-Wunused-variable]
   23 |         int idx = 1;
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...