Submission #396900

#TimeUsernameProblemLanguageResultExecution timeMemory
396900pavementCombo (IOI18_combo)C++17
97 / 100
51 ms672 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
 
char rev[4];
 
string guess_sequence(int N) {
	rev[0] = 'A';
	rev[1] = 'B';
	rev[2] = 'X';
	rev[3] = 'Y';
	int ans = 0;
	string tmp = "AB", curr;
	if (press(tmp)) {
		tmp = "A";
		if (press(tmp)) curr = "A";
		else curr = "B", ans = 1;
	} else {
		tmp = "X";
		if (press(tmp)) curr = "X", ans = 2;
		else curr = "Y", ans = 3;
	}
	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:40:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   if (x == curr.size() + 1) curr += notans[0];
      |       ~~^~~~~~~~~~~~~~~~~~
combo.cpp:41:14: 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 (x == curr.size() + 2) curr += notans[1];
      |            ~~^~~~~~~~~~~~~~~~~~
combo.cpp:48:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   if (press(tmp) == tmp.size()) {
      |       ~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:53:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |  if (curr.size() < N) curr += notans.back();
      |      ~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...