이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string a="ABXY";
string pas="XABY";
/*int press(string s){
int r=0;
string b="";
for(int k=0;k<pas.size();k++){
b=b+pas[k];
if(s.find(b)==-1)
return r;
r++;
}
return r;
}*/
string guess_sequence(int N){
int r=1,d=0;
string s="";
while(s.size()<N){
for(int k=0;k<a.size();k++){
string b=s+a[k];
if(k==3-d){
s=b;
r++;
if(r==2){
if(b=="A")
a.erase(0,1);
if(b=="B")
a.erase(1,1);
if(b=="X")
a.erase(2,1);
if(b=="Y")
a.erase(3,1);
d++;
}
break;
}
else
if(press(b)==r){
s=b;
r++;
if(r==2){
if(b=="A")
a.erase(0,1);
if(b=="B")
a.erase(1,1);
if(b=="X")s=b;
r++;
if(r==2){
if(b=="A")
a.erase(0,1);
if(b=="B")
a.erase(1,1);
if(b=="X")
a.erase(2,1);
if(b=="Y")
a.erase(3,1);
d++;
}
break;
a.erase(2,1);
if(b=="Y")
a.erase(3,1);
}
break;
}
}
}
return s;
}
/*int main(){
string s=guess_sequence(pas.size());
cout<<s;
return 0;
}*/
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:21:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
21 | while(s.size()<N){
| ~~~~~~~~^~
combo.cpp:23:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int k=0;k<a.size();k++){
| ~^~~~~~~~~
combo.cpp:62:1: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
62 | if(b=="Y")
| ^~
combo.cpp:64:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
64 | d++;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |