Submission #543366

#TimeUsernameProblemLanguageResultExecution timeMemory
543366Blobo2_Blobo2Combo (IOI18_combo)C++14
5 / 100
1 ms320 KiB
#include<bits/stdc++.h>
#include "combo.h"
//#include "grader.cpp"
using namespace std;
//#define int long long
//#define endl "\n"
#define all(v)  v.begin(),v.end()
#define gen(arr,n,nxt)  generate(arr,arr+n,nxt)
#define Blobo2 ios_base::sync_with_stdio(false);cin.tie(0);

char le[]={'A','B','X','Y'};
string guess_sequence(int n){
	string t = "AB";
	//cout<<t<<endl;
	int x = press(t);
	if(x == 2) t = "A";
	else if(x){
		t = "B";
		//cout<<t<<endl;
		x=press(t);
		if(!x)
			t = "A";
	}
	else{
		t = "X";
		//cout<<t<<endl;
		x = press(t);
		if(!x)
			t = "Y";
	}
	int idx = 0;
	for(int i=0;i<4;i++){
		if(le[i] == t[0]){
			idx = i;
			break;
		}
	}
	for(int i=1;i<n-1;i++){
		string test;
		test += t;
		test += le[(idx+1)%4];
		test += t;
		test += le[(idx+2)%4];
		test += le[(idx+1)%4];
		test += t;
		test += le[(idx+2)%4];
		test += le[(idx+2)%4];
		test += t;
		test += le[(idx+2)%4];
		test += le[(idx+3)%4];
		//cout<<t<<' '<<t.size()<<endl;
		x = press(test);

		if(x == (int)t.size())
			t += le[(idx+3)%4];
		else if(x == (int)t.size()+1)
			t += le[(idx+1)%4];
		else
			t += le[(idx+2)%4];
		//cout<<t<<endl;
	}
	t += le[(idx+1)%4];
	x = press(t);
	if(x == n)
        return t;
    t.pop_back();
    t += le[(idx+2)%4];
    x = press(t);
    if(x == n)
        return t;
    t.pop_back();
    t += le[(idx+3)%4];
    return t;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...