이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
string s;
int coins = press("AB");
if (coins >= 1){
if (press("A")){
s = "A";
moves = {"X", "B", "Y"};
}
else{
s = "B";
moves = {"A", "X", "Y"};
}
}
else{
if (press("X")){
s = "X";
moves = {"A", "B", "Y"};
}
else{
s = "Y";
moves = {"A", "B", "X"};
}
}
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 < 2; i++){
string guess = s + moves[i];
if (press(guess) == s.size() + 1) return guess;
}
return s + moves[2];
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
45 | while (s.size() < n - 1){
| ~~~~~~~~~^~~~~~~
combo.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | if (coins == s.size()) s += moves[2];
| ~~~~~~^~~~~~~~~~~
combo.cpp:50:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | else if (coins == s.size() + 1) s += moves[0];
| ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:51:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | else if (coins == s.size() + 2) s += moves[1];
| ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:57:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | if (press(guess) == s.size() + 1) return guess;
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |