Submission #421455

#TimeUsernameProblemLanguageResultExecution timeMemory
421455alishahali1382Combo (IOI18_combo)C++14
97 / 100
44 ms724 KiB
#include "combo.h"
#include<bits/stdc++.h>
#pragma GCC optimize ("O2")
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> piii;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<"{"<<#x<<", "<<#y<<"}={"<<x<<", "<<y<<"}\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define debugv(abcd) {cerr<<#abcd<<": ";for (auto dcba:abcd) cerr<<dcba<<", "; cerr<<"\n";}
#define pb push_back
#define SZ(x) ((int)x.size())
#define all(x) x.begin(), x.end()

const int inf=1000001000; // 1e9
const ll INF=10000000010000000ll; // 1e16
const int mod=1000000007;
const int MAXN=300010;

string S;
string alpha="ABXY";

char get(int x){
	for (char ch:alpha) if (ch!=S[0] && !(x--)) return ch;
	assert(0);
	return 'Z';
}

string guess_sequence(int n){
	if (press("AB")){
		if (press("A")) S="A";
		else S="B";
	}
	if (press("XY")){
		if (press("X")) S="X";
		else S="Y";
	}
	if (n==1) return S;
	while (SZ(S)+2<=n){
		string SX=S+get(0);
		string SYX=S+get(1)+get(0);
		string SYY=S+get(1)+get(1);
		string SYZ=S+get(1)+get(2);
		int res=press(SX+SYX+SYY+SYZ)-SZ(S);
		if (res==0) S+=get(2);
		if (res==1) S+=get(0);
		if (res==2) S+=get(1);
	}
	if (press(S+get(0))==n) S+=get(0);
	else if (press(S+get(1))==n) S+=get(1);
	else S+=get(2);
	return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...