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