Submission #729809

# Submission time Handle Problem Language Result Execution time Memory
729809 2023-04-24T16:03:12 Z 2vas Combo (IOI18_combo) C++17
0 / 100
65 ms 208 KB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include "combo.h"
using namespace std;


string guess_sequence(int N) {
	// get first letter
	int n = N;

	char first;
	char other[3];

	if (press("AB")) {
		if (press("A")) {
			first = 'A';
			other[0] = 'B';
			other[1] = 'X';
			other[2] = 'Y';
		} else {
			first = 'B';
			other[0] = 'A';
			other[1] = 'X';
			other[2] = 'Y';
		}
	} else {
		if (press("X")) {
			first = 'X';
			other[0] = 'B';
			other[1] = 'A';
			other[2] = 'Y';
		} else {
			first = 'Y';
			other[0] = 'A';
			other[1] = 'X';
			other[2] = 'B';
		}
	}

	string s = "" + first;

	while ((int) s.length() < n - 1) {
		string p = s + other[0] + other[1];
		p += s + other[0] + other[2];
		p += s + other[1] + other[2];
		int v = press(p);

		if (v == 0 + (int) s.length()) {
			s += other[2];
			continue;
		}

		if (v == 1 + (int) s.length()) {
			p = s + other[1] + other[1];
			v = press(p);
			if (v == 0 + (int) s.length()) {
				s += other[0] + other[0];
			} else if (v == 1 + (int) s.length()) {
				s += other[1] + other[0];
			} else {
				assert(v == 2 + (int) s.length());
				s += other[1] + other[1];
			}
			continue;
		}

		if (v == 2 + (int) s.length()) {
			p = s + other[0] + other[1];
			v = press(p);
			if (v == 0 + (int) s.length()) {
				s += other[1] + other[2];
			} else if (v == 1 + (int) s.length()) {
				s += other[0] + other[2];
			} else {
				assert(v == 2 + (int) s.length());
				s += other[0] + other[1];
			}
			continue;
		}
	}

	if ((int) s.length() == n) {
		return s;
	}


	if (press(s + other[0] + s + other[1]) == n) {
		if (press(s + other[0]) == n) {
			s += other[0];
		} else {
			s += other[1];
		}
	} else {
		s += other[2];
	}

	return s;

}
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 208 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Wrong Answer: wrong guess.
2 Halted 0 ms 0 KB -