Submission #1330644

#TimeUsernameProblemLanguageResultExecution timeMemory
1330644developinpopCombo (IOI18_combo)C++20
100 / 100
7 ms484 KiB
/*
_____________________.
|____________________|   $$\                                                            $$\           $$\        $$\               
|____________________|   $$ |                                                           \__|          $$ |       $$ |              
|____________________| $$$$$$\    $$$$$$\  $$$$$$\  $$$$$$$\   $$$$$$$\        $$$$$$\  $$\  $$$$$$\  $$$$$$$\ $$$$$$\    $$$$$$$\ 
|____________________| \_$$  _|  $$  __$$\ \____$$\ $$  __$$\ $$  _____|      $$  __$$\ $$ |$$  __$$\ $$  __$$\\_$$  _|  $$  _____|
|____________________|   $$ |    $$ |  \__|$$$$$$$ |$$ |  $$ |\$$$$$$\        $$ |  \__|$$ |$$ /  $$ |$$ |  $$ | $$ |    \$$$$$$\  
                         $$ |$$\ $$ |     $$  __$$ |$$ |  $$ | \____$$\       $$ |      $$ |$$ |  $$ |$$ |  $$ | $$ |$$\  \____$$\ 
                         \$$$$  |$$ |     \$$$$$$$ |$$ |  $$ |$$$$$$$  |      $$ |      $$ |\$$$$$$$ |$$ |  $$ | \$$$$  |$$$$$$$  |
            へ   ♡        \____/ \__|      \_______|\__|  \__|\_______/       \__|      \__| \____$$ |\__|  \__|  \____/ \_______/ 
         ૮ - ՛)                                                                             $$\   $$ |    
         / ⁻ ៸|                                                                              \$$$$$$  |   are human rights :3
     乀 (ˍ,ل ل                       													     \______/ 

*/
#include "combo.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, 
                         tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<pair<T, long long>, null_type, 
                      less<pair<T, long long>>, rb_tree_tag, 
                         tree_order_statistics_node_update>;

#define ll int 
#define ull unsigned long long
#define ld long double
#define inf (ll)1e13+31
#define pb push_back
#define se second
#define fi first
#define endl '\n'
#define mp make_pair
#define pll pair<ll,ll>
#define kth_smallest find_by_order
#define num_of_smaller order_of_key
#define fori(x) for(ll i=0;i<x;i++)
#define forj(y) for(ll j=0;j<y;j++)

//#define DEBUG

#ifdef DEBUG
#define show(x) cerr<<#x<<" is "<<x<<endl;
#define show2(x,y) cerr<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<endl;
#define show3(x,y,z) cerr<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<" "<<#z<<" is "<<z<<endl;
#define show4(x,y,z,a) cerr<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<" "<<#z<<" is "<<z<<" "<<#a<<" is "<<a<<endl;
#define show_vec(a) for(auto &i:a)cerr<<i<<" ";cerr<<endl;
#define skillissue cerr<<"your code is running\n";
#define getchar_unlocked _getchar_nolock // comment before submission
#else
#define show(x)
#define show2(x,y)
#define show3(x,y,z)
#define show4(x,y,z,a)
#define show_vec(a)
#define skillissue
#endif

/*

inline int readint() {
    int x=0; char ch=getchar_unlocked(); bool s=1;
    while(ch<'0'||ch>'9'){if(ch=='-')s=0;ch=getchar_unlocked();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar_unlocked();}
    return s?x:-x;
}

*/


string guess_sequence(int N) {
	string p = "";
	vector<char> chars = {'A', 'B', 'X', 'Y'};
	ll qry1 = press("AB");
	ll qry2 = press("BX");
		if(mp(qry1, qry2) == mp(0,0)){
			p = "Y";
		} else if(mp(qry1, qry2) == mp(1,0)){
			p = "A";
		} else if(mp(qry1, qry2) == mp(0,1)){
			p = "X";
		} else if(mp(qry1, qry2) == mp(1,1)){
			p = "B";
		} else if(mp(qry1, qry2) == mp(2,0)){
			p = "AB";
		} else if(mp(qry1, qry2) == mp(1,2)){
			p = "BX";
		}
	chars = {};
	if('A'!=p[0])chars.pb('A');
	if('B'!=p[0])chars.pb('B');
	if('X'!=p[0])chars.pb('X');
	if('Y'!=p[0])chars.pb('Y');
	while(p.length() < N-1){
		string eee = p + chars[0] + p + chars[1] + chars[1] + p + chars[1] + chars[2] + p + chars[1] + chars[0];
		ll qry = press(eee);
		if(qry == p.length())p += chars[2];
		else if(qry == p.length()+1)p += chars[0];
		else p += chars[1];
	}
	if(p.length()==N)return p;
	if(press(p+chars[0])==N)return p+chars[0];
	if(press(p+chars[1])==N)return p+chars[1];
	return p+chars[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...