# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217767 | 2fat2code | Secret Permutation (RMI19_permutation) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "combo.h"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
//#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;
const int mod=1e9+7;
const int modp=1999999973;
const int modulo=998244353;
vector<char>ch;
vector<char>ch2;
string guess_sequence(int N) {
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
srand(chrono::steady_clock::now().time_since_epoch().count());
string tz;
ch.push_back('A'); ch.push_back('B'); ch.push_back('X'); ch.push_back('Y');
tz="A";
if(press(tz)==1) goto next;
tz="B";
if(press(tz)==1) goto next;
tz="X";
if(press(tz)==1) goto next;
tz="Y";
next:;
for(int i=0;i<ch.size();i++){
if(ch[i]!=tz.back()) ch2.push_back(ch[i]);
}
for(int i=1;i<(N-1);i++){
random_shuffle(all(ch2));
cout << endl;
string ask=(tz+ch2[0]+ch2[0]+tz+ch2[0]+ch2[1]+tz+ch2[0]+ch2[2]+tz+ch2[1]);
int g=press(ask);
if(g==(i+2)) tz.push_back(ch2[0]);
else if(g==(i+1)) tz.push_back(ch2[1]);
else tz.push_back(ch2[2]);
}
if(N>=2){
tz+="A";
if(press(tz)==N) goto next1;
tz.pop_back();
tz+="B";
if(press(tz)==N) goto next1;
tz.pop_back();
tz+="X";
if(press(tz)==N) goto next1;
tz.pop_back();
tz+="Y";
next1:;
}
return tz;
}