이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include<bits/stdc++.h>
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
char gf(){
int c = press("AB");
if(c > 0){
int a = press("A");
if(a){
return 'A';
}else{
return 'B';
}
}else{
int x = press("X");
if(x){
return 'X';
}else{
return 'Y';
}
}
}
char gl(string ans,vector<char> vec){
int c = press(ans+vec[0]);
if(c == ans.length()+1){
return vec[0];
}
c = press(ans+vec[1]);
if(c == ans.length()+1){
return vec[1];
}
return vec[2];
}
std::string guess_sequence(int n) {
char f = gf();
vector<char> rem;
string opt = "ABXY";
FOR(i,0,4){
if(opt[i] != f){
rem.push_back(opt[i]);
}
}
string ans = "";
ans += f;
FOR(i,1,n-1){
string cur = ans+rem[0]+ans+rem[1]+rem[0]+ans+rem[1]+rem[1]+ans+rem[1]+rem[2];
int c = press(cur);
if(c == ans.length()){
ans += rem[2];
}else if(c == ans.length()+1){
ans += rem[0];
}else{
ans += rem[1];
}
}
if(n > 1){
char l = gl(ans,rem);
ans += l;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'char gl(std::string, std::vector<char>)':
combo.cpp:28:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | if(c == ans.length()+1){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if(c == ans.length()+1){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:52:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | if(c == ans.length()){
| ~~^~~~~~~~~~~~~~~
combo.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | }else if(c == ans.length()+1){
| ~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |