제출 #99120

#제출 시각아이디문제언어결과실행 시간메모리
99120JustasLe콤보 (IOI18_combo)C++17
0 / 100
1 ms328 KiB
#include "combo.h"
#include <bits/stdc++.h>
 
using namespace std;
 
string guess_sequence(int N) {
	set<char> X = {'A', 'B', 'X', 'Y'};
	string s = "";
	for (auto it = X.begin(); it != X.end(); it++) {
		int x = press(s + *it);
		if (x != 0) {
			s += *it;
			X.erase(it);
			break; 
		}
	}
	if (s == "") {
		return s;
	}
	int prev = 1;
	bool ok = true;
	string e = "";
	while (ok) {
		ok = false;
		int sz = (int) s.size(), esz = (int) e.size();
		for (auto it = X.begin(); it != X.end(); it++) {
			if ((N - 1) % esz == 0 && (N - 1) / esz > 1) {
				string p = "";
				for (int i = 0; i < (N - 1) / esz - 1; i++) {
					p += e;
				}
				int x = press(s + p);
				if (x > prev) {
					s += p;
					prev = x;
					ok = true;
					break;
				}
			}
			string poss = s + *it;
			int d = N - sz;
			string t = "";
			for (int j = 0; j < d; j++) {
				t += *it;
			}
			int x = press(s + t);
			if (x > prev) {
				for (int j = 0; j < x - prev; j++) {
					e += *it;
					s += *it;
				}
				ok = true;
				prev = x;
				break;
			}
		}
	}
	return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...