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 <iostream>
#include "combo.h"
#include <algorithm>
#include <functional>
#include <random>
#include <cmath>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <string>
#include <bitset>
#include <numeric>
#include <iomanip>
#include <limits.h>
#include <tuple>
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("avx2")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pp;
//#define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl
#define per(i,r,l) for(int i = (r); i >= (l); i--)
#define rep(i,l,r) for(int i = (l); i < (r); i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ss second
#define ff first
//void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name; *iss >>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);}
const ll mod = 1e9 + 7, maxn = 2e5 + 5, lg = 21, inf = ll(1e18) + 5;
string guess_sequence(int n){
string ans;
vector<char> ch = {'A', 'B', 'X', 'Y'};
int r = press("AB");
if(r) {
r = press("A");
if(r) ans += 'A';
else ans += 'B';
} else{
r = press("X");
if(r) ans += 'X';
else ans += 'Y';
}
ch.erase(find(all(ch), ans[0]));
if(n == 1) return ans;
while(sz(ans) < n-1){
string ask;
ask += ans + ch[0] + ch[0];
ask += ans + ch[0] + ch[1];
ask += ans + ch[0] + ch[2];
ask += ans + ch[1];
ans += ch[press(ask)-sz(ans)];
}
string ask = ans + ch[0] + ans + ch[1];
if(press(ask) > sz(ans)){
ask = ans + ch[0];
if(press(ask) > sz(ans)) ans += ch[0];
else ans += ch[1];
}else ask += ch[2];
return ans;
}
//int main(){
// cin.tie(0) -> sync_with_stdio(0);
// int n; cin >> n;
// string ans;
// vector<char> ch = {'A', 'B', 'X', 'Y'};
// int r = press("AB");
// if(r) {
// r = press("A");
// if(r) ans += 'A';
// else ans += 'B';
// } else{
// r = press("X");
// if(r) ans += 'X';
// else ans += 'Y';
// }
// ch.erase(find(all(ch), ans[0]));
// if(n == 1) {
// cout << ans << '\n';
// return 0;
// }
// while(sz(ans) < n-1){
// string ask;
// ask += ans + ch[0] + ch[0];
// ask += ans + ch[0] + ch[1];
// ask += ans + ch[0] + ch[2];
// ask += ans + ch[1];
// ans += ch[2-press(ask)];
// }
// string ask = ans + ch[0] + ans + ch[1];
// if(press(ask)){
// ask = ans + ch[0];
// if(press(ask)) ans += ch[0];
// else ans += ch[1];
// }else ask += ch[2];
// cout << ans << '\n';
// return 0;
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |