이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <string>
#include <vector>
#include <iostream>
using namespace std;
std::string guess_sequence(int N) {
vector<char> but = {'A','B','X','Y'};
string s = "";
//find first
char start='1';
for(char c : but){
if(c=='Y'){
s.push_back(c);
start=c;
break;
}
if(press(string(1,c))==1){
s.push_back(c);
start=c;
break;
}
}
if(start=='A'){
but={'B','X','Y'};
}
else if(start=='B'){
but={'A','X','Y'};
}
else if(start=='X'){
but={'A','B','Y'};
}
else{
but={'A','B','X'};
}
for(int i=1;i<N-1;i++){
string q="";
q.append(s);
q.push_back(but[0]);
q.append(s);
q.push_back(but[1]);
q.push_back(but[0]);
q.append(s);
q.push_back(but[1]);
q.push_back(but[1]);
q.append(s);
q.push_back(but[1]);
q.push_back(but[2]);
//cout<<q<<endl;
int qu=press(q);
if(qu==i+0){
s.push_back(but[2]);
}
else if(qu==i+1){
s.push_back(but[0]);
}
else{
s.push_back(but[1]);
}
//cout<<qu<<endl;
//cout<<s.back()<<endl;
}
//now get last element
if(s.size()<N){
for(int i=0;i<2;i++){
s.push_back(but[i]);
if(press(s)==N){
break;
}
s.pop_back();
}
if(s.size()<N){
s.push_back(but[2]);
}
}
//cout<<s<<endl;
return s;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:68:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
68 | if(s.size()<N){
| ~~~~~~~~^~
combo.cpp:76:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
76 | if(s.size()<N){
| ~~~~~~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |