제출 #346444

#제출 시각아이디문제언어결과실행 시간메모리
346444lebasivillar콤보 (IOI18_combo)C++14
100 / 100
41 ms552 KiB
#include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include <vector> #include "combo.h" using namespace std; string guess_sequence(int N){ string t; if (press("AB") > 0){ if (press("A") > 0) t.push_back('A'); else t.push_back('B'); } else { if (press("X") > 0) t.push_back('X'); else t.push_back('Y'); } if (N == 1) return t; string sequence = "ABXY"; vector <string> left; for (int i = 0; i < sequence.size(); ++i){ if (sequence[i] != t[0]) { string word; word.push_back(sequence[i]); left.push_back(word); } } vector <string> ends = {left[1], left[2] + left[0], left[2] + left[1], left[2]+ left[2]}; while (t.size() < N - 1){ int value = press(t + ends[0] + t + ends[1] + t + ends[2] + t + ends[3]) -t.size(); if (value == 0) t += left[0]; if (value == 1) t += left[1]; if (value == 2) t += left[2]; } if (press(t + left[0]) == N) t += left[0]; else if (press(t + left[1]) == N) t += left[1]; else t += left[2]; return t; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for (int i = 0; i < sequence.size(); ++i){
      |                   ~~^~~~~~~~~~~~~~~~~
combo.cpp:30:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   while (t.size() < N - 1){
      |          ~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...