이 제출은 이전 버전의 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;
}
void remove(vector<char> &subset, char c)
{
subset.erase(find(subset.begin(), subset.end(), c));
}
std::string guess_sequence(int N)
{
vector<char> available = {'A', 'B', 'X', 'Y'};
string cur = "";
int query1 = Press("AB"), query2 = Press("BX");
if (query1 == 2)
cur = "A";
else if (query2 == 2)
cur = "B";
else if (query1 == 0)
{
switch (query2)
{
case 0:
cur = "Y";
break;
case 1:
cur = "X";
break;
}
}
else if (query1 == 1)
{
switch (query2)
{
case 0:
cur = "A";
break;
case 1:
cur = "B";
break;
}
}
remove(available, cur[0]);
while (cur.size() < N)
{
if (cur.size() == N - 1)
{
string toPress = cur + available[0] + cur + available[1];
if (Press(toPress) == cur.size())
cur += available[2];
else if (Press(cur + available[0]) == N)
cur += available[0];
else
cur += available[1];
continue;
}
string toPress = cur + available[0];
for (int i = 0; i < 3; i++)
toPress += cur + available[1] + available[i];
int query = Press(toPress);
if (query == cur.size())
cur += available[2];
else if (query == cur.size() + 1)
cur += available[0];
else
cur += available[1];
}
return cur;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:53:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | while (cur.size() < N)
| ~~~~~~~~~~~^~~
combo.cpp:55:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
55 | if (cur.size() == N - 1)
| ~~~~~~~~~~~^~~~~~~~
combo.cpp:58:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | if (Press(toPress) == cur.size())
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:72:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | if (query == cur.size())
| ~~~~~~^~~~~~~~~~~~~
combo.cpp:74:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | else if (query == cur.size() + 1)
| ~~~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |