이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 1e5+1, oo = 1e9;
std::string guess_sequence(int N) {
int n = N;
string but = "ABXY";
if(press("AB")) {
swap(but[press("B")], but[0]);
} else {
swap(but[press("Y")+2], but[0]);
}
string pref;
pref+=but[0];
if(n==1) return pref;
for(int i=1;i<n-1;++i) {
string query = pref+but[1];
for(int j=1;j<4;++j) {
query+=pref+but[2]+but[j];
}
int coins = press(query);
if(coins == pref.size()) {
pref+=but[3];
} else if(coins == pref.size()+1) {
pref+=but[1];
} else {
pref+=but[2];
}
}
// check last character
random_shuffle(but.begin()+1, but.end());
if(press(pref+but[1]+pref+but[2])==n) {
if(press(pref+but[1])==n) {
pref+=but[1];
} else pref+=but[2];
} else pref+=but[3];
return pref;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | if(coins == pref.size()) {
| ~~~~~~^~~~~~~~~~~~~~
combo.cpp:32:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | } else if(coins == pref.size()+1) {
| ~~~~~~^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |