이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "combo.h"
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define coord pair<int, int>
const int MOD = 1e9 + 7;
const int MAXN = 1e3;
// int dp[MAXN];
namespace {
constexpr int MAX_N = 2000;
constexpr int MAX_NUM_MOVES = 8000;
int N;
string S;
int num_moves;
void wrong_answer(const char *MSG) {
printf("Wrong Answer: %s\n", MSG);
exit(0);
}
} // namespace
string guess_sequence(int N) {
// find first letter in 2 presses
int res;
res = press("AB");
string f;
if (res >= 1) {
res = press("A");
if (res == 1) {
f = "A";
} else {
f = "B";
}
} else {
res = press("X");
if (res == 1) {
f = "X";
} else {
f = "Y";
}
}
if (N==1) {
return f;
}
vector<string> chars = {"A", "B", "X", "Y"};
chars.erase(find(chars.begin(), chars.end(), f));
// cout << "left letters:" << endl;
// for (string c : chars) {
// cout << c << endl;
// }
// cout << endl;
string ans = f;
for (int i=1; i<N-1; i++) {
// chars has length 3
// excluding last character from chars
string g = ans + chars[0];
g += ans + chars[1] + chars[0];
g += ans + chars[1] + chars[1];
g += ans + chars[1] + chars[2];
res = press(g);
if (res == (int)ans.length()) {
ans += chars[2];
} else if (res == (int)ans.length()+1) {
ans += chars[0];
} else {
ans += chars[1];
}
}
// guess last letter
res = press(ans + chars[0] + ans + chars[1]);
if (res == N) {
res = press(ans + chars[0]);
if (res == N) {
ans += chars[0];
} else {
ans += chars[1];
}
} else {
ans += chars[2];
}
cout << "My answer: " << ans << endl;
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp:23:6: warning: 'void {anonymous}::wrong_answer(const char*)' defined but not used [-Wunused-function]
23 | void wrong_answer(const char *MSG) {
| ^~~~~~~~~~~~
combo.cpp:21:5: warning: '{anonymous}::num_moves' defined but not used [-Wunused-variable]
21 | int num_moves;
| ^~~~~~~~~
combo.cpp:18:5: warning: '{anonymous}::N' defined but not used [-Wunused-variable]
18 | int N;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |