이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string s;
/*long long press(string t){
cout << t << endl;
long long ans;
cin >> ans;
return ans;
}*/
long long ask(string t){
return (long long) press(t);
}
string guess_sequence(int N){
long long a=0,b=0,x=0,y=0;
long long n = N;
if(ask("AB") >= 1){
if(ask("B") == 1){
b = 1;
}
else{
a = 1;
}
}
else{
if(ask("X") == 1){
x = 1;
}
else{
y = 1;
}
}
if(a){
s += "A";
if(n == 1){
return s;
}
for(long i = 1; i <= n-2; i++){
string r = s + "B" + s + "XY" + s + "XB" + s + "XX";
long long rez = ask(r);
if(rez == i+1){
s += "B";
}
if(rez == i+2){
s += "X";
}
if(rez == i){
s += "Y";
}
}
string r = s+"B",e = s+"X";
long long r1 = ask(r);
if(r1 == n){
return r;
}
long long r2 = ask(e);
if(r2 == n){
return e;
}
return s+"Y";
}
if(b){
s += "B";
if(n == 1){
return s;
}
for(long i = 1; i <= n-2; i++){
string r = s + "A" + s + "XY" + s + "XA" + s + "XX";
long long rez = ask(r);
if(rez == i+1){
s += "A";
}
if(rez == i+2){
s += "X";
}
if(rez == i){
s += "Y";
}
}
string r = s+"A",e = s+"X";
long long r1 = ask(r);
if(r1 == n){
return r;
}
long long r2 = ask(e);
if(r2 == n){
return e;
}
return s+"Y";
}
if(x){
s += "X";
if(n == 1){
return s;
}
for(long i = 1; i <= n-2; i++){
string r = s + "A" + s + "BY" + s + "BA" + s + "BB";
long long rez = ask(r);
if(rez == i+1){
s += "A";
}
if(rez == i+2){
s += "B";
}
if(rez == i){
s += "Y";
}
}
string r = s+"B",e = s+"Y";
long long r1 = ask(r);
if(r1 == n){
return r;
}
long long r2 = ask(e);
if(r2 == n){
return e;
}
return s+"A";
}
if(y){
s += "Y";
if(n == 1){
return s;
}
for(long i = 1; i <= n-2; i++){
string r = s + "A" + s + "BX" + s + "BA" + s + "BB";
long long rez = ask(r);
if(rez == i+1){
s += "A";
}
if(rez == i+2){
s += "B";
}
if(rez == i){
s += "X";
}
}
string r = s+"B",e = s+"X";
long long r1 = ask(r);
if(r1 == n){
return r;
}
long long r2 = ask(e);
if(r2 == n){
return e;
}
return s+"A";
}
}
/*int main(){
cout << guess_sequence(1) << endl;
}*/
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:149:1: warning: control reaches end of non-void function [-Wreturn-type]
149 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |