Submission #955569

# Submission time Handle Problem Language Result Execution time Memory
955569 2024-03-31T03:13:40 Z horiseun Combo (IOI18_combo) C++17
0 / 100
1 ms 344 KB
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include "combo.h"
using namespace std;

string guess_sequence(int N) {
	char x, y, z, w;
	if (press("AB")) {
		z = 'X';
		w = 'Y';
		if (press("A")) {
			x = 'A';
			y = 'B';
		} else {
			x = 'B';
			y = 'A';
		}
	} else {
		z = 'A';
		w = 'B';
		if (press("X")) {
			x = 'X';
			y = 'Y';
		} else {
			x = 'Y';
			y = 'X';
		}
	}
	string ret = "";
	ret += x;
	for (int i = 1, tmp; i < N - 1; i++) {
		string query = ret + y + ret + z + y + ret + z + z + ret + z + w;
		tmp = press(query);
		if (tmp == ret.size() + 2) {
			ret += z;
		} else if (tmp == ret.size() + 1) {
			ret += y;
		} else {
			ret += w;
		}
	}
	if (press(ret + y) == N) {
		ret += y;
	} else if (press(ret + z) == N) {
		ret += z;
	} else {
		ret += w;
	}
	cout << ret << "\n";
	return ret;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   if (tmp == ret.size() + 2) {
      |       ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   } else if (tmp == ret.size() + 1) {
      |              ~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -