이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
ios_base::sync_with_stdio(0);\
cin.tie(0);\
cout.tie(0)\
string guess_sequence(int n) {
string res = "";
vector<string> v;
if(press("AB")){
if(press("A")) res = "A", v = {"B", "X", "Y"};
else res = "B", v = {"A", "X", "Y"};
}
else{
if(press("X")) res = "X", v = {"A", "B", "Y"};
else res += "Y", v = {"A", "B", "X"};
}
if(n == 1)return res;
for(int i = 1; i <= n - 2; i++){
string cur = res + v[0] + v[0] + res + v[0] + v[1] + res + v[0] + v[2] + res + v[1];
int q = press(cur);
if(q == res.size() + 2) res += v[0];
else if(q == res.size() + 1) res += v[1];
else res += v[2];
}
if(press(res + "A" + res + "B") == res.size() + 1){
if(press(res + "A") == res.size() + 1) res += "A";
else res += "B";
}
else{
if(press(res + "X") == res.size() + 1) res += "X";
else res += "Y";
}
return res;
}
/*
res + BX
res + BB
res + BY
res + X
*/
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | if(q == res.size() + 2) res += v[0];
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | else if(q == res.size() + 1) res += v[1];
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:40:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if(press(res + "A" + res + "B") == res.size() + 1){
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:41:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | if(press(res + "A") == res.size() + 1) res += "A";
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:45:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if(press(res + "X") == res.size() + 1) res += "X";
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |