이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "combo.h"
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const ll mod = 998244353;
ld fpow(ld a, ll b, ll m)
{
a;
ld res = 1;
while (b > 0)
{
if (b % 2 == 1)
{
res = res * a;
}
a = a * a;
b /= 2;
}
return res;
}
std::string guess_sequence(int N)
{
string x = "ABXY", y;
char z;
string ans;
ll b = press("A");
if (b)
{
ans.push_back('A');
y = "BXBXXXY";
z = 'Y';
}
else if (press("B"))
{
ans.push_back('B');
y = "AXAXYXX";
z = 'Y';
}
else if (press("X"))
{
ans.push_back('X');
y = "ABABYBB";
z = 'Y';
}
else
{
ans.push_back('Y');
y = "ABABXBB";
z = 'X';
}
cout << ans << ' ';
for (int i = 1; i < N-1; i++)
{
b = press(ans + y.substr(0, 1) + ans + y.substr(1, 2) + ans + y.substr(3, 2) + ans + y.substr(5, 2));
if (b == ans.size() + 1)
{
ans.push_back(y[0]);
}
else if (b == ans.size() + 2)
{
ans.push_back(y[1]);
}
else
{
ans.push_back(z);
}
}
if(press(ans+'A'+ans+'B')!=ans.size())
{
if(press(ans+'A') !=ans.size())
{
ans.push_back('A');
}
else
{
ans.push_back('B');
}
}
else
{
if(press(ans+'X') !=ans.size())
{
ans.push_back('X');
}
else
{
ans.push_back('Y');
}
}
cout << ans<<' ';
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'ld fpow(ld, ll, ll)':
combo.cpp:15:5: warning: statement has no effect [-Wunused-value]
15 | a;
| ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:62:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | if (b == ans.size() + 1)
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:66:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | else if (b == ans.size() + 2)
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:75:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | if(press(ans+'A'+ans+'B')!=ans.size())
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:77:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
77 | if(press(ans+'A') !=ans.size())
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:88:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
88 | if(press(ans+'X') !=ans.size())
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |