제출 #713282

#제출 시각아이디문제언어결과실행 시간메모리
713282europium콤보 (IOI18_combo)C++17
91 / 100
40 ms580 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <numeric> #include <cmath> #include <iterator> #include <set> #include <map> #include <math.h> #include <iomanip> #include <unordered_set> #include "combo.h" using namespace std; string guess_sequence(int n) { vector<string> moves = {"A", "B", "X", "Y"}; string s = ""; for (int i = 0; i < 4; i++){ string guess = moves[i]; if (press(guess) == 1){ s += moves[i]; auto it = find(moves.begin(), moves.end(), guess); moves.erase(it); break; } } if (n == 1) return s; while (s.size() < n - 1){ string guess = s + moves[0] + s + moves[1] + moves[0] + s + moves[1] + moves[1] + s + moves[1] + moves[2]; int coins = press(guess); if (coins == s.size()) s += moves[2]; else if (coins == s.size() + 1) s += moves[0]; else if (coins == s.size() + 2) s += moves[1]; } for (int i = 0; i < 3; i++){ string guess = s + moves[i]; if (press(guess) == s.size() + 1){ s += moves[i]; break; } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |     while (s.size() < n - 1){
      |            ~~~~~~~~~^~~~~~~
combo.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         if (coins == s.size()) s += moves[2];
      |             ~~~~~~^~~~~~~~~~~
combo.cpp:40:24: 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 (coins == s.size() + 1) s += moves[0];
      |                  ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:41:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         else if (coins == s.size() + 2) s += moves[1];
      |                  ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         if (press(guess) == s.size() + 1){
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...