Submission #855650

# Submission time Handle Problem Language Result Execution time Memory
855650 2023-10-01T15:46:29 Z franfill Password (RMI18_password) C++17
0 / 100
1 ms 344 KB
#include<bits/stdc++.h>
using namespace std;

int query(string str);
int query(string S, bool rv)
{
	if (rv)
		reverse(S.begin(), S.end());
	return query(S);
}

void solve(int i, vector < bool > us, bool rv, string& cur, int N, int S)
{
	if (cur.size() == N)
		return;
	for (int c = 0; c < S; c++)
		if (us[c])
		{
			string tr = cur.substr(0, i);	
			tr += char('a'+c);
			tr += cur.substr(i, cur.size()-i);
			if (query(tr, rv) == tr.size())
			{
				cur = tr;
				solve(i, us, rv, cur, N, S);
				solve(i+1, us, rv, cur, N, S);
				return;
			}
			else
				us[c] = false;
		}
}

string guess(int N, int S)
{	
	return "wtf";
	string cur;
	vector < bool > us(S, true);
	for (int c = 0; c < S; c++)
		if (query(string(1, c+'a')) == true)
		{
			cur = string(1, c+'a');
			break;
		}
		else
			us[c] = false;
	solve(1, us, false, cur, N, S);
	reverse(cur.begin(), cur.end());
	solve(cur.size(), us, true, cur, N, S);
	reverse(cur.begin(), cur.end());
	return cur;
}

Compilation message

password.cpp: In function 'void solve(int, std::vector<bool>, bool, std::string&, int, int)':
password.cpp:14:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |  if (cur.size() == N)
      |      ~~~~~~~~~~~^~~~
password.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    if (query(tr, rv) == tr.size())
      |        ~~~~~~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Token "wtf" doesn't correspond to pattern "[a-o]{1,15}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Token "wtf" doesn't correspond to pattern "[a-b]{1,50}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Token "wtf" doesn't correspond to pattern "[a-l]{1,1000}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Token "wtf" doesn't correspond to pattern "[a-o]{1,15}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Token "wtf" doesn't correspond to pattern "[a-o]{1,15}"
2 Halted 0 ms 0 KB -