Submission #139723

#TimeUsernameProblemLanguageResultExecution timeMemory
139723KewoCombo (IOI18_combo)C++17
100 / 100
41 ms648 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

string s;
set<char> ost;
vector<char> oth;

std::string guess_sequence(int N) {
	ost.insert('A');
	ost.insert('B');
	ost.insert('X');
	ost.insert('Y');

	if(press("AB") != 0) {
		if(press("A") != 0) {
			s.pb('A');
			ost.erase('A');
		}
		else {
			s.pb('B');
			ost.erase('B');
		}
	}
	else {
		if(press("X") != 0) {
			s.pb('X');
			ost.erase('X');
		}
		else {
			s.pb('Y');
			ost.erase('Y');
		}
	}
	for(auto i : ost)
		oth.pb(i);

	for(int i = 1; i < N - 1; i++) {
		string ask = s + oth[0] + s + oth[1] + oth[0] + s + oth[1] + oth[1] + s + oth[1] + oth[2];
		int re = press(ask);
		if(re == (int)s.size())
			s.pb(oth[2]);
		if(re == (int)s.size() + 1)
			s.pb(oth[0]);
		if(re == (int)s.size() + 2)
			s.pb(oth[1]);
	}
	if(N != 1) {
		if(press(s + oth[0] + s + oth[1]) == (int)s.size() + 1) {
			if(press(s + oth[0]) == (int)s.size() + 1)
				return s + oth[0];
			else
				return s + oth[1];
		}
		else
			return s + oth[2];
	}
	return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...