Submission #961832

#TimeUsernameProblemLanguageResultExecution timeMemory
961832Gr1senCombo (IOI18_combo)C++17
100 / 100
16 ms2220 KiB
#include "combo.h"
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define vi vector<int>
#define vvi vector<vi>


string guess_sequence(int n) {
	string ans, but;
	if (press("AB")) {
		if (press("A")) {
			ans = "A";
			but = "BXY";
		}
		else {
			ans = "B";
			but = "AXY";
		}
	}
	else {
		if (press("X")) {
			ans = "X";
			but = "ABY";
		}
		else {
			ans = "Y";
			but = "ABX";
		}
	}
	if (n == 1) return ans;
	while (ans.size() < n-1) {
		//cerr << "press : " << ans + but[0] + ans + but[1] + but[0] + ans + but[1] + but[1] + ans + but[1] + but[2] << endl;
		int k = press(ans + but[0] + ans + but[1] + but[0] + ans + but[1] + but[1] + ans + but[1] + but[2]);
		if (k == ans.size() + 1) {
			ans += but[0];
			continue;
		}
		if (k == ans.size() + 2) {
			ans += but[1];
			continue;
		}
		ans += but[2];
	}
	if (press(ans + but[0]) == n) return (ans + but[0]);
	if (press(ans + but[1]) == n) return (ans + but[1]);
	return ans + but[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |  while (ans.size() < n-1) {
      |         ~~~~~~~~~~~^~~~~
combo.cpp:38:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   if (k == ans.size() + 1) {
      |       ~~^~~~~~~~~~~~~~~~~
combo.cpp:42:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   if (k == ans.size() + 2) {
      |       ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...