Submission #396898

#TimeUsernameProblemLanguageResultExecution timeMemory
396898pavement콤보 (IOI18_combo)C++17
94 / 100
47 ms588 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

char rev[4];
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string guess_sequence(int N) {
	rev[0] = 'A';
	rev[1] = 'B';
	rev[2] = 'X';
	rev[3] = 'Y';
	shuffle(rev, rev + 4, rng);
	int ans = 0;
	for (int i = 1; i <= 3; i++) {
		string tmp;
		tmp = rev[i];
		if (press(tmp)) {
			ans = i;
			break;
		}
	}
	string curr;
	curr = rev[ans];
	vector<char> notans;
	for (int i = 0; i <= 3; i++)
		if (i != ans) notans.push_back(rev[i]);
	for (int i = 1; i < N - 1; i++) {
		string tmp = curr;
		tmp += notans[0];
		tmp += curr;
		tmp += notans[1];
		tmp += notans[0];
		tmp += curr;
		tmp += notans[1];
		tmp += notans[1];
		tmp += curr;
		tmp += notans[1];
		tmp += notans[2];
		int x = press(tmp);
		if (x == curr.size() + 1) curr += notans[0];
		else if (x == curr.size() + 2) curr += notans[1];
		else curr += notans[2];
	}
	for (int i = 0; i < (int)notans.size() - 1; i++) {
		char c = notans[i];
		string tmp = curr;
		tmp += c;
		if (press(tmp) == tmp.size()) {
			curr.push_back(c);
			break;
		}
	}
	if (curr.size() < N) curr += notans.back();
	return curr;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:41:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   if (x == curr.size() + 1) curr += notans[0];
      |       ~~^~~~~~~~~~~~~~~~~~
combo.cpp:42:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   else if (x == curr.size() + 2) curr += notans[1];
      |            ~~^~~~~~~~~~~~~~~~~~
combo.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   if (press(tmp) == tmp.size()) {
      |       ~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:54:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |  if (curr.size() < N) curr += notans.back();
      |      ~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...