Submission #203866

#TimeUsernameProblemLanguageResultExecution timeMemory
203866staniewzkiCombo (IOI18_combo)C++17
30 / 100
41 ms300 KiB
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

mt19937 rng(2137);
int rd(int a, int b) {
	return uniform_int_distribution<int>(a, b)(rng);
}

#include "combo.h"

string guess_sequence(int n) {
	string guess(n, 'A');
	if(press("AB")) {
		if(press("A")) guess[0] = 'A';
		else guess[0] = 'B';
	}
	else {
		if(press("X")) guess[0] = 'X';
		else guess[0] = 'Y';
	}

	auto letter_id = [&](char c) {
		REP(i, 4) if("ABXY"[i] == c) 
			return i;
	};

	auto get_letter = [&](vector<bool> banned) {
		int x;
		do x = rd(0, 3);
		while(banned[x]);
		return "ABXY"[x];
	};

	vector<bool> used(4);
	used[letter_id(guess[0])] = true;
	FOR(i, 1, n - 1)
		guess[i] = get_letter(used);


	int cur = press(guess);
	FOR(i, 1, n - 1) {
		auto banned = used;
		while(cur <= i) {
			banned[letter_id(guess[i])] = true;
			debug(i, banned, guess, cur);
			guess[i] = get_letter(banned);
			cur = press(guess);
			debug(guess, cur);
		}
	}

	return guess;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:83:32: warning: statement has no effect [-Wunused-value]
   83 |    debug(i, banned, guess, cur);
      |                                ^
combo.cpp:86:21: warning: statement has no effect [-Wunused-value]
   86 |    debug(guess, cur);
      |                     ^
combo.cpp: In lambda function:
combo.cpp:63:2: warning: control reaches end of non-void function [-Wreturn-type]
   63 |  };
      |  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...