제출 #991076

#제출 시각아이디문제언어결과실행 시간메모리
991076fv3Combo (IOI18_combo)C++14
5 / 100
1 ms344 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; typedef long long ll; string guess_sequence(int N) { char first; string sequence; if (press("AB")) first = (press("A") ? 'A' : 'B'); else first = (press("X") ? 'X' : 'Y'); sequence += first; // q = 2 char c[3] = {'A', 'B', 'X'}; if (first == 'A') c[0] = 'Y'; else if (first == 'B') c[1] = 'Y'; else if (first == 'X') c[2] = 'Y'; for (int i = 1; i < N - 1; i++) { int n = press(sequence + c[0] + c[0] + sequence + c[0] + c[1] + sequence + c[0] + c[2] + sequence + c[1]); if (n == sequence.size()) sequence += c[2]; else if (n == sequence.size() + 1) sequence += c[1]; else sequence += c[0]; } // q = N if (press(sequence + c[0] + sequence + c[1]) == N) sequence += (press(sequence + c[0]) == N ? c[0] : c[1]); else sequence += c[2]; return sequence; } // Let A be the first letter // Guess the following: // AXB AXX AXY AY // N = 3 -> X // N = 2 -> Y // N = 1 -> B // // Using this strategy I can find all letters in sequence up to N - 1 in N guesses: // I can find the last value in 2 guesses

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         if (n == sequence.size()) sequence += c[2];
      |             ~~^~~~~~~~~~~~~~~~~~
combo.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         else if (n == sequence.size() + 1) sequence += c[1];
      |                  ~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...