이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include "combo.h"
//#define int long long
#define loop(X, N) for(int X = 0; X < (N); X++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef uint64_t u64;
typedef int64_t i64;
int press(string p);
string guess_sequence(int n)
{
vector<char> others = { 'A', 'B', 'X', 'Y' };
string guess;
if (press("AB"))
{
if (press("A"))
{
guess = "A";
others.erase(others.begin() + 0);
}
else
{
guess = "B";
others.erase(others.begin() + 1);
}
}
else
{
if (press("X"))
{
guess = "X";
others.erase(others.begin() + 2);
}
else
{
guess = "Y";
others.erase(others.begin() + 3);
}
}
if (n == 1)
return guess;
while (guess.size() < size_t(n) - 1)
{
int result = press((guess + others[0]) + (guess + others[1] + others[0]) + (guess + others[1] + others[1]) + (guess + others[1] + others[2]));
if (result == guess.size())
{
guess += others[2];
}
else if (result == guess.size() + 1)
{
guess += others[0];
}
else
{
guess += others[1];
}
}
if (press(guess + others[0] + guess + others[1]) == n)
{
if (press(guess + others[0]) == n)
return guess + others[0];
else
return guess + others[1];
}
else
return guess + others[2];
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:76:14: 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 (result == guess.size())
| ~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:80:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
80 | else if (result == guess.size() + 1)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |