이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <string>
using namespace std;
string getGuess(int N, string s, char c) {
string cur = "";
int am = 1;
while (cur.size() + s.size() + am <= N * 4) {
cur += s + string(am, c);
am++;
}
return cur;
}
string guess_sequence(int N) {
string s = "";
int oldcoins = 0;
while (s.size() < N) {
if (s.size() == 0) {
if (press(s + "A") > oldcoins) {
oldcoins++;
s += "A";
} else if (press(s + "B") > oldcoins) {
oldcoins++;
s += "B";
} else if (press(s + "X") > oldcoins) {
oldcoins++;
s += "X";
} else if (press(s + "Y") > oldcoins) {
oldcoins++;
s += "Y";
}
} else {
s += string(press(getGuess(N, s, 'A')) - s.size(), 'A');
if (s.size() >= N) break;
s += string(press(getGuess(N, s, 'B')) - s.size(), 'B');
if (s.size() >= N) break;
s += string(press(getGuess(N, s, 'X')) - s.size(), 'X');
if (s.size() >= N) break;
s += string(press(getGuess(N, s, 'Y')) - s.size(), 'Y');
if (s.size() >= N) break;
}
}
return s;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string getGuess(int, std::string, char)':
combo.cpp:8:39: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
8 | while (cur.size() + s.size() + am <= N * 4) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:18:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
18 | while (s.size() < N) {
| ~~~~~~~~~^~~
combo.cpp:35:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
35 | if (s.size() >= N) break;
| ~~~~~~~~~^~~~
combo.cpp:37:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | if (s.size() >= N) break;
| ~~~~~~~~~^~~~
combo.cpp:39:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
39 | if (s.size() >= N) break;
| ~~~~~~~~~^~~~
combo.cpp:41:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
41 | if (s.size() >= N) break;
| ~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |