Submission #1241616

#TimeUsernameProblemLanguageResultExecution timeMemory
1241616whatisdpCombo (IOI18_combo)C++17
100 / 100
8 ms492 KiB
#ifndef G
#include "combo.h"
#endif
#include <map>

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

std::string guess_sequence(int N) {
	std::map<std::string, int> ccs;
	using str = std::string;
	str s;
	for(int i=0;i<4;i++) ccs[cs[i]]=i;
	int l=0;
	if (press("AB")) {
		s += (press("A") ? "A" : "B");
	}
	else s += (press("X") ? "X" : "Y");
	swap(cs[ccs[s]], cs[3]);
	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) {
			s += (press(s + cs2[0]) == N ? cs2[0] : cs2[1]);
		}
		else s += cs2[2];
	}
	return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...