이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
#define ALL(x) x.begin(), x.end()
using namespace std;
string guess_sequence(int N)
{
vector<char> buttons = {'A', 'B', 'X', 'Y'};
string S;
// std::random_device rd;
// std::mt19937 g(rd());
// uniform_int_distribution<int> dist(0, 2);
while (S.size() < N)
{
// shuffle(buttons.begin(), buttons.end(), g);
for (int c = 0; c < buttons.size(); c++)
{
string p = S + buttons[c];
if (c == buttons.size() - 1)
{
S = p;
if (S.size() == 0)
{
buttons.erase(find(ALL(buttons), buttons[c]));
if (buttons.size() == 4)
throw;
}
break;
}
else
{
if (S.size() > 0)
{
while (p.size() < 4 * N)
{
int rand = 0;
// rand = dist(rd);
p += buttons[rand];
}
}
int res = press(p);
if (res > S.size())
{
S = string(p.begin(), p.begin() + res);
if (S.size() == 0)
{
buttons.erase(find(ALL(buttons), buttons[c]));
if (buttons.size() == 4)
throw;
}
break;
}
}
}
}
return S;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:14:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
14 | while (S.size() < N)
| ~~~~~~~~~^~~
combo.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for (int c = 0; c < buttons.size(); c++)
| ~~^~~~~~~~~~~~~~~~
combo.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | if (c == buttons.size() - 1)
| ~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:35:27: 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 (p.size() < 4 * N)
| ~~~~~~~~~^~~~~~~
combo.cpp:43:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | if (res > S.size())
| ~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |