Submission #494373

# Submission time Handle Problem Language Result Execution time Memory
494373 2021-12-15T10:55:02 Z Itamar Password (RMI18_password) C++14
Compilation error
0 ms 0 KB
#include <iostream>
using namespace std;

string guess(int n, int s) {
	string x;
	return rec(n, s, x, 0);
}

string rec(int n, int s, string x, int it) {
	if (x.size() == n) {
		return x;
	}
	for (int i = 0; i < s; i++) {
		x[it] = 96 + i;
		if (query(x) == x.size()) {
			return rec(n, s, x, it + 1);
		}
	}
	x[it] = x[it - 1];
	it--;
	return rec(n, s, x, it);
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:7:9: error: 'rec' was not declared in this scope
    7 |  return rec(n, s, x, 0);
      |         ^~~
password.cpp: In function 'std::string rec(int, int, std::string, int)':
password.cpp:11:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   11 |  if (x.size() == n) {
      |      ~~~~~~~~~^~~~
password.cpp:16:7: error: 'query' was not declared in this scope
   16 |   if (query(x) == x.size()) {
      |       ^~~~~