제출 #76780

#제출 시각아이디문제언어결과실행 시간메모리
76780MatheusLealV콤보 (IOI18_combo)C++17
100 / 100
47 ms564 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; int t = press("AB"); if(t > 0) { int a = press("A"); if(a == 1) pref = "A"; else pref = "B"; } else { int a = press("X"); if(a == 1) pref = "X"; else pref = "Y"; } 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:42:12: 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(ans == pref.size() + 1) pref.push_back(c[1]);
      |        ~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     else if(ans == pref.size() + 2) pref.push_back(c[2]);
      |             ~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:55:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |       if(press(aux) == pref.size() + 1)
      |          ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...