이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define nax 200005
#define pb push_back
#define sc second
#define fr first
//#define int long long
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
/*
namespace {
constexpr int MAX_N = 2000;
constexpr int MAX_NUM_MOVES = 8000;
int N;
std::string S;
int num_moves;
void wrong_answer(const char *MSG) {
printf("Wrong Answer: %s\n", MSG);
exit(0);
}
} // namespace
int press(std::string p) {
if (++num_moves > MAX_NUM_MOVES) {
wrong_answer("too many moves");
}
int len = p.length();
if (len > 4 * N) {
wrong_answer("invalid press");
}
for (int i = 0; i < len; ++i) {
if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') {
wrong_answer("invalid press");
}
}
int coins = 0;
for (int i = 0, j = 0; i < len; ++i) {
if (j < N && S[j] == p[i]) {
++j;
} else if (S[0] == p[i]) {
j = 1;
} else {
j = 0;
}
coins = std::max(coins, j);
}
return coins;
}
*/
string guess_sequence(int n)
{
string s;
vector<char> a(4);
a[0] = 'A'; a[1] = 'B'; a[2] = 'X'; a[3] = 'Y';
int k;
char exclude;
if(press("AB") >= 1)
{
if(press("A") >= 1)
{
exclude = 'A';
}
else
{
exclude = 'B';
}
}
else
{
if(press("X") >= 1)
{
exclude = 'X';
}
else
{
exclude = 'Y';
}
}
s.pb(exclude);
a.erase(find(all(a), exclude));
for(int i = 0; i < n-2; i++)
{
string now = s;
now+=a[0];
now+=a[0];
now+=s;
now+=a[0];
now+=a[1];
now+=s;
now+=a[0];
now+=a[2];
now+=s;
now+=a[1];
k = press(now);
if(k == s.size()+2)
{
s.pb(a[0]);
continue;
}
if(k == s.size()+1)
{
s.pb(a[1]);
continue;
}
if(k == s.size())
{
s.pb(a[2]);
}
}
if(s.size() < n)
{
if(press(s+a[0]) == s.size()+1)
{
s+=a[0];
}
else if(press(s+a[1]) == s.size()+1)
{
s+=a[1];
}
else
{
s+=a[2];
}
}
return s;
}
/*
int main() {
char buffer[MAX_N + 1];
if (scanf("%s", buffer) != 1) {
fprintf(stderr, "Error while reading input\n");
exit(1);
}
S = buffer;
N = S.length();
num_moves = 0;
std::string answer = guess_sequence(N);
if (answer != S) {
wrong_answer("wrong guess");
exit(0);
}
printf("Accepted: %d\n", num_moves);
return 0;
return 0;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:112:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
112 | if(k == s.size()+2)
| ~~^~~~~~~~~~~~~
combo.cpp:117:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
117 | if(k == s.size()+1)
| ~~^~~~~~~~~~~~~
combo.cpp:122:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
122 | if(k == s.size())
| ~~^~~~~~~~~~~
combo.cpp:127:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
127 | if(s.size() < n)
| ~~~~~~~~~^~~
combo.cpp:129:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
129 | if(press(s+a[0]) == s.size()+1)
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:133:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
133 | else if(press(s+a[1]) == s.size()+1)
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |