이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
int Press(string s)
{
// cout << s << ": ";
int ans = press(s);
// cout << ans << endl;
return ans;
}
std::string guess_sequence(int N)
{
vector<char> available = {'A', 'B', 'X', 'Y'};
string cur = "";
int a1 = Press("AB");
int a2 = Press("XY");
auto case2 = [&cur, &available](string pressed)
{
// cout << "Case 2: " << pressed << '\n';
cur = pressed;
available.erase(find(available.begin(), available.end(), pressed[0]));
};
auto case1 = [&cur, &available, &case2](string pressed)
{
// cout << "Case 1: " << pressed << '\n';
bool isFirst = Press({pressed[0]});
if (isFirst)
case2({pressed[0]});
else
case2({pressed[1]});
};
if (a1 == 2)
case2("AB");
else if (a2 == 2)
case2("XY");
else if (a1 == 1)
case1("AB");
else if (a2 == 1)
case1("XY");
while (cur.size() < N)
{
int query = Press(cur + available[0] + available[1]);
if (query == cur.size() + 2)
cur += (string() + available[0] + available[1]);
else if (query == cur.size() + 1)
cur += available[0];
else if (query == cur.size())
{
query = Press(cur + available[1]);
if (query == cur.size() + 1)
cur += available[1];
else if (query == cur.size())
cur += available[2];
}
}
return cur;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:46:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | while (cur.size() < N)
| ~~~~~~~~~~~^~~
combo.cpp:49:13: 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 (query == cur.size() + 2)
| ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:51:18: 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 (query == cur.size() + 1)
| ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | else if (query == cur.size())
| ~~~~~~^~~~~~~~~~~~~
combo.cpp:56:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | if (query == cur.size() + 1)
| ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | else if (query == cur.size())
| ~~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |