이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int N){
string A = "A",B = "B",C = "X",D = "Y";
string ans;
if(press("AB")){
if(press("A"))ans = "A",swap(A,D);
else ans = "B",swap(B,D);
}
else {
if(press("X")) ans = "X",swap(C,D);
else ans = "Y";
}
if(N == 2){
if(press(ans + A) == 2) ans = ans + A;
else if(press (ans + B )== 2 ) ans = ans +B;
else ans = ans + C;
}
if(ans.size() == N)return ans;
for(int i = 1;i< N-2;i++){
string query = ans + B + ans + C + A + ans + C + B + ans + C + C;
int res = press(query);
if (res == i) ans = ans +A;
else if(res == i+1) ans = ans + B;
else ans = ans + C;
}
int res = press(ans + A + B + ans + B + A) - N +2;
if(res == 0){
res = press(ans + C + A + ans + C + B)- N +2;
ans = ans + (res == 1 ? C + C : (press(ans + C + A)- N +2 == 2 ? C + A : C + B));
}
else if (res == 2){
res = press(ans + A + B) - N +2 ;
ans = ans + (res == 2 ? A + B : B + A);
}
else {
res = press(ans + A + A + ans + B + B) - N +2 ;
ans = ans + (res == 2 ? ( press(ans + A + A) - N +2 == 0 ? B + B : A + A) : (press (ans + A + C) - N +2 == 0 ? B + C : A + C));
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | if(ans.size() == N)return ans;
| ~~~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |