이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 2*1e5+5, INF = 4e18+9;
std::string guess_sequence(int N) {
int n = N;
string ss[4] = {"A", "B", "X", "Y"};
char c[4] = {'A', 'B', 'X', 'Y'};
string s;
string t;
t = s+"A"+s+"B";
if(press(t) > s.size()){
t = s+"A";
if(press(t) > s.size()){
s.push_back('A');
}else{
s.push_back('B');
}
}else{
t = s+"X";
if(press(t)){
s.push_back('X');
}else{
s.push_back('Y');
}
}
if(n == 1) return s;
for(int i = 2; i < n; i++){
string t;
int cnt = 0;
vector<int> d(3);
for(int j = 0; j <= 3; j++){
if(s[0] == c[j]) continue;
if(cnt == 2){
d[2] = j;
break;
}
if(cnt == 0){
for(int k = 0; k <= 3; k++){
if(s[0] == c[k]) continue;
t+=s;
t.push_back(c[j]);
t.push_back(c[k]);
}
d[0] = j;
}else{
t+=s;
t.push_back(c[j]);
d[1] = j;
}
cnt++;
}
int res = press(t);
if(res == 1+s.size()){
s.push_back(c[d[1]]);
}else if(res == 2+s.size()){
s.push_back(c[d[0]]);
}else{
s.push_back(c[d[2]]);
}
}
t = s+"A"+s+"B";
if(press(t) > s.size()){
t = s+"A";
if(press(t) > s.size()){
s.push_back('A');
}else{
s.push_back('B');
}
}else{
t = s+"X";
if(press(t) > s.size()){
s.push_back('X');
}else{
s.push_back('Y');
}
}
return s;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | if(press(t) > s.size()){
| ~~~~~~~~~^~~~~~~~~~
combo.cpp:17:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | if(press(t) > s.size()){
| ~~~~~~~~~^~~~~~~~~~
combo.cpp:58:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | if(res == 1+s.size()){
| ~~~~^~~~~~~~~~~~~
combo.cpp:60:22: 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(res == 2+s.size()){
| ~~~~^~~~~~~~~~~~~
combo.cpp:67:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | if(press(t) > s.size()){
| ~~~~~~~~~^~~~~~~~~~
combo.cpp:69:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | if(press(t) > s.size()){
| ~~~~~~~~~^~~~~~~~~~
combo.cpp:76:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
76 | if(press(t) > s.size()){
| ~~~~~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |