Submission #1015439

#TimeUsernameProblemLanguageResultExecution timeMemory
1015439TroySerCombo (IOI18_combo)C++17
0 / 100
1 ms344 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N) {

	string LETTERS = "ABXY";

	char firsty;
	if (press("AB") == 1) {
		if (press("A") == 1) firsty = 'A';
		else firsty = 'B';
	} else {
		if (press("X") == 1) firsty = 'X';
		else firsty = 'Y';
	}
	
	string currString = "";
	currString += firsty;

	if (N == 1) {
		return currString;
	}

	char ind[3];
	int indy = 0;
	for (int i = 0; i < LETTERS.size(); i++) {
		if (LETTERS[i] != firsty) {
			ind[indy] = LETTERS[i];
			indy++;
		}
	}

	for (int i = 1; i < N-1; i++) {
		cout << currString + ind[0] + currString + ind[1] + ind[0] + currString + ind[1] + ind[1] + currString + ind[1] + ind[2] << "\n";
		int res = press(currString + ind[0] + currString + ind[1] + ind[0] + currString + ind[1] + ind[1] + currString + ind[1] + ind[2]);
		if (res == currString.size()) {
			currString += ind[2];
		} else if (res == currString.size() + 1) {
			currString += ind[0];
		} else {
			currString += ind[1];
		}
	}

	if (press(currString + "A" + currString + "B") == 1) {
		if (press(currString + "A") == 1) currString += "A";
		else currString += "B";
	} else {
		if (press(currString + "X") == 1) currString += "X";
		else currString += "Y";
	}

	return currString;

}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for (int i = 0; i < LETTERS.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~~
combo.cpp:37:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   if (res == currString.size()) {
      |       ~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   } else if (res == currString.size() + 1) {
      |              ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...