제출 #76779

#제출 시각아이디문제언어결과실행 시간메모리
76779MatheusLealV콤보 (IOI18_combo)C++17
97 / 100
50 ms464 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; char c[4] = {'A', 'B', 'X', 'Y'}; string guess_sequence(int n) { string pref; for(int i = 0; i < 3; i++) { string a; a.push_back(c[i]); if(press(a) == 1) { pref = a; break; } a.pop_back(); } if(pref.empty()) pref.push_back(c[3]); for(int i = 0; i < 4; i++) if(c[i] == pref[0]) swap(c[i], c[0]); for(int j = 0; j < n - 2; j++) { string aux = pref + c[1] + pref + c[2] + c[3] + pref + c[2] + c[1] + pref + c[2] + c[2]; int ans = press(aux); if(ans == pref.size() + 1) pref.push_back(c[1]); else if(ans == pref.size() + 2) pref.push_back(c[2]); else pref.push_back(c[3]); } if(n != 1) { for(int i = 1; i < 3; i++) { string aux = pref + c[i]; if(press(aux) == pref.size() + 1) { return aux; } } pref += c[3]; } return pref; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     if(ans == pref.size() + 1) pref.push_back(c[1]);
      |        ~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     else if(ans == pref.size() + 2) pref.push_back(c[2]);
      |             ~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |       if(press(aux) == pref.size() + 1)
      |          ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...