Submission #99207

#TimeUsernameProblemLanguageResultExecution timeMemory
99207eriksuenderhaufCombo (IOI18_combo)C++11
100 / 100
50 ms532 KiB
#include <bits/stdc++.h>
#include "combo.h"
#define vi vector<int>
#define pb push_back
using namespace std;
const int MAXN = 2e5 + 50;
char c[3];

string guess_sequence(int N) {
	string p = "";
	int val = press("AB");
	if (val == 2) {
		p = "AB";
		c[0] = 'B', c[1] = 'X', c[2] = 'Y';
	} else if (val == 1) {
		val = press("A");
		if (val == 1) {
			p = "A";
			c[0] = 'B', c[1] = 'X', c[2] = 'Y';
		} else {
			p = "B";
			c[0] = 'A', c[1] = 'X', c[2] = 'Y';
		}
	} else {
		val = press("X");
		if (val == 1) {
			p = "X";
			c[0] = 'A', c[1] = 'B', c[2] = 'Y';
		} else {
			p = "Y";
			c[0] = 'A', c[1] = 'B', c[2] = 'X';
		}
	}
	if (p.size() == N)
		return p;
	while (p.size() < N - 1) {
		string tmp = p + c[0] + c[0] + p + c[0] + c[1] + p + c[0] + c[2] + p + c[1];
		val = press(tmp);
		if (val == p.size() + 2)
			p += c[0];
		else if (val == p.size() + 1)
			p += c[1];
		else
			p += c[2];
	}
	if (press(p + c[0]) == N)
		return p + c[0];
	else if (press(p + c[1]) == N)
		return p + c[1];
	return p + c[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |  if (p.size() == N)
      |      ~~~~~~~~~^~~~
combo.cpp:36:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |  while (p.size() < N - 1) {
      |         ~~~~~~~~~^~~~~~~
combo.cpp:39:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   if (val == p.size() + 2)
      |       ~~~~^~~~~~~~~~~~~~~
combo.cpp:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   else if (val == p.size() + 1)
      |            ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...