#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
string res;
vector<char> op={'A', 'B', 'X', 'Y'}, new_op;
char st;
for (int i=0; i<4; i++) if (press(string(1, op[i]))==1) st=op[i], res=op[i];
if (N==1) return res;
for (int i=0; i<4; i++) if (st!=op[i]) new_op.push_back(op[i]);
for (int i=1; i<N-1; i++)
{
string s=(res+new_op[0])+(res+new_op[1]+new_op[0])+(res+new_op[1]+new_op[1])+(res+new_op[1]+new_op[2]);
int p=press(s);
if (p==res.size()) res+=new_op[2];
else if (p==res.size()+1) res+=new_op[0];
else res+=new_op[1];
}
for (int i=0; i<3; i++) if (press(res+new_op[i])==N) return res+new_op[i];
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:1: warning: control reaches end of non-void function [-Wreturn-type]
22 | }
| ^| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |