이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <string>
#include <vector>
using namespace std;
#define BUT "ABXY"
string guess_sequence(int N)
{
string ans(2, 0);
int j = 0, fst = -1;
vector<int> non(2005, 0);
for (int i = 0; i < 4; ++i)
{
if (i == 3) ans[0] = 'Y', ++j;
else
{
ans[0] = BUT[i];
ans[1] = 'A';
int k = press(ans);
if (k == 1) ++j, non[1] |= 1;
if (k == 2) j += 2;
if (k >= 1) { fst = i; break; }
}
}
for (int j = 1; j < N; ++j) non[j] |= (1 << fst);
for (int i = j; i < N - 1;)
{
int nxt = i + 1;
for (int j = 0; j < 4; j++)
{
if (j == 3)
ans[i] = 'Y';
else
{
if (non[i] & (1 << j)) continue;
ans.resize(i+2);
ans[i] = BUT[j];
ans[i+1] = 'A';
int k = press(ans);
if (k == i + 1) non[i+1] |= 1;
if (k == i + 2) nxt = i + 2;
if (k >= i + 1) break;
}
}
i = nxt;
}
ans.resize(N);
for (int j = 0; j < 4; j++)
{
if (j == 3)
ans[N-1] = 'Y';
else
{
if (non[N-1] & (1 << j)) continue;
ans[N-1] = BUT[j];
int k = press(ans);
if (k == N) break;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |