이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <stack>
#include <map>
#include <math.h>
#include <bitset>
#include <deque>
#include <string>
#include <tuple>
#include <queue>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#define pi 3.141592653589793238
#define ll long long
#define ld long double
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define mod 1000000007ll
#define INF 1000000000000000000
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin (), (x).end ()
#define sz(x) (ll) (x).size ()
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())
#define rank rnk
#define log lg
#define fast \
ios_base::sync_with_stdio (false); \
cin.tie (NULL); \
cout.tie (NULL)
using namespace std;
int press(string p);
vector <char> pos={'A','B','X','Y'};
vector <char> p1={'A','B'};
vector <char> p2={'X','Y'};
string setup(string ans)
{
int out=press(ans+p1[0]+ans+p1[1]);
if(out>=sz(ans)+1)
{
out=press(ans+p1[0]);
if(out==sz(ans)+1)
ans.pb('A');
else
ans.pb('B');
}
else
{
out=press(ans+p2[0]);
if(out==sz(ans)+1)
ans.pb('X');
else
ans.pb('Y');
}
return ans;
}
string guess_sequence(int n)
{
string ans="";
ans=setup(ans);
vector <char> avail;
for(auto c:pos)
if(c!=ans[0])
avail.pb(c);
rep(i,1,n-2)
{
int out=press(ans+avail[0]+ans+avail[1]+avail[0]+ans+avail[1]+avail[1]+ans+avail[1]+avail[2]);
if(out==sz(ans))
ans.pb(avail[2]);
else if(out==sz(ans)+1)
ans.pb(avail[0]);
else
ans.pb(avail[1]);
}
if(sz(ans)!=n)
ans=setup(ans);
return ans;
}
// signed main()
// {
// fast;
// freopen("milkorder.in","r",stdin);
// freopen("milkorder.out","w",stdout);
// string s=guess_sequence(1);
// cout<<s<<endl;
// return 0;
// }
// int press(string p)
// {
// cout<<p<<endl;
// fflush(stdout);
// int x;
// cin>>x;
// return x;
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |