이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
void uradi(string &upit,string s,char prvo){
char niz[4];
niz[0]='A';niz[1]='B';niz[2]='X';niz[3]='Y';
bool bio=false;
for(int i=0;i<4;i++){
if(niz[i]==prvo) continue;
if(bio){
for(int j=0;j<4;j++){
if(niz[j]!=prvo){
upit+=s;
upit+=niz[i];
upit+=niz[j];
}
}
break;
}else{
bio=true;
upit+=s;
upit+=niz[i];
}
}
}
string guess_sequence(int n){
// freopen("out.txt","a",stdout);
string s="";
char prvo;
if(press("AB")>0){
if(press("A")>0){
s+='A';
prvo='A';
}else{
s+='B';
prvo='B';
}
}else{
if(press("X")>0){
s+='X';
prvo='X';
}else{
s+='Y';
prvo='Y';
}
}
// cout<<"evo:"<<s<<"\n";
char niz[4];
niz[0]='A';niz[1]='B';niz[2]='X';niz[3]='Y';
for(int p=1;p<n-1;p++){
string upit="";
uradi(upit,s,prvo);
int nesto=press(upit);
for(int i=0,j=0;i<4;i++){
if(niz[i]==prvo) continue;
if(j==0 && nesto==s.size()+1){
s+=niz[i];
break;
}else if(j==1 && nesto==s.size()+2){
s+=niz[i];
break;
}else if(j==2 && nesto==s.size()){
s+=niz[i];
break;
}
j++;
}
// cout<<"evo:"<<s<<" "<<nesto<<"\n";
}
if(press(s+"A"+s+"B")>s.size()){
if(press(s+"A")>s.size()){
s+='A';
}else{
s+='B';
}
}else{
if(press(s+"X")>s.size()){
s+='X';
}else{
s+='Y';
}
}
return s;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:57:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | if(j==0 && nesto==s.size()+1){
| ~~~~~^~~~~~~~~~~~
combo.cpp:60:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | }else if(j==1 && nesto==s.size()+2){
| ~~~~~^~~~~~~~~~~~
combo.cpp:63:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | }else if(j==2 && nesto==s.size()){
| ~~~~~^~~~~~~~~~
combo.cpp:71:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | if(press(s+"A"+s+"B")>s.size()){
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~
combo.cpp:72:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | if(press(s+"A")>s.size()){
| ~~~~~~~~~~~~^~~~~~~~~
combo.cpp:78:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | if(press(s+"X")>s.size()){
| ~~~~~~~~~~~~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |