Submission #1241613

#TimeUsernameProblemLanguageResultExecution timeMemory
1241613whatisdpCombo (IOI18_combo)C++17
94 / 100
7 ms492 KiB

#ifndef G
#include "combo.h"
#endif

std::string cs[4] = {"A", "B", "X", "Y"};

std::string guess_sequence(int N) {
	using str = std::string;
	str s;
	int l=0;
	for (int i=0;i<4;i++) {
		if (press(cs[i])) {
			s = cs[i];
			swap(cs[i], cs[3]);
			break;
		}
	}
	str cs2[3];
	for(int i=0;i<3;i++) {
		cs2[i] = cs[i];
	}
	
	for(int i=0;i<3;i++) {
		// std::cout<<i<<" : \""<<cs2[i]<<"\"\n";
	}
	
	for (int i=1;i<N-1;i++) {
		str z;
		for(int j=0;j<3;j++) z += s + cs2[0] + cs2[j];
		z += s + cs2[1];
		int r = press(z);
		if (r == i+2) s += cs2[0];
		else if (r == i+1) s += cs2[1];
		else s += cs2[2];
	}
	if (N > 1) {
		str z = s + cs2[0] + s + cs2[1];
		int r = press(z);
		if (r == N) {
			return s + (press(s + cs2[0]) == N ? cs2[0] : cs2[1]);
		}
		else return s + cs2[2];
	}
	else return s;
	return "";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...