Submission #709095

# Submission time Handle Problem Language Result Execution time Memory
709095 2023-03-13T06:12:37 Z jamezzz Password (RMI18_password) C++17
30 / 100
184 ms 360 KB
#include <bits/stdc++.h>
using namespace std;

mt19937 rng(time(0));

int query(string str);

string guess(int n,int s){
	string ans="";
	int pv=0;
	vector<int> v;
	for(int i=0;i<s;++i)v.push_back(i);
	shuffle(v.begin(),v.end(),rng);
	for(int i:v){
		char c='a'+i;
		for(int j=0;j<ans.length();++j){
			string tmp=ans;
			tmp.insert(j,1,c);
			int res=query(tmp);
			if(res>pv){
				pv=res;
				swap(tmp,ans);
				tmp.clear();
				if(pv==n)return ans;
				continue;
			}
			else{
				tmp.clear();
				if(res==j)break;
			}
		}
		string tmp=ans;
		tmp.insert(tmp.length(),n-tmp.length(),c);
		pv=query(tmp);
		tmp.resize(pv);
		swap(ans,tmp);
		tmp.clear();
		if(pv==n)return ans;
	}
	return ans;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:16:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   for(int j=0;j<ans.length();++j){
      |               ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 91 queries.
2 Correct 3 ms 208 KB Guessed the password with 207 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 48 queries.
2 Correct 2 ms 228 KB Guessed the password with 115 queries.
3 Runtime error 1 ms 304 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 85 ms 312 KB Guessed the password with 6178 queries.
2 Correct 101 ms 356 KB Guessed the password with 10383 queries.
3 Correct 129 ms 360 KB Guessed the password with 11408 queries.
4 Correct 184 ms 356 KB Guessed the password with 22160 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 91 queries.
2 Correct 3 ms 208 KB Guessed the password with 207 queries.
3 Correct 1 ms 208 KB Guessed the password with 48 queries.
4 Correct 2 ms 228 KB Guessed the password with 115 queries.
5 Runtime error 1 ms 304 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 91 queries.
2 Correct 3 ms 208 KB Guessed the password with 207 queries.
3 Correct 1 ms 208 KB Guessed the password with 48 queries.
4 Correct 2 ms 228 KB Guessed the password with 115 queries.
5 Runtime error 1 ms 304 KB Execution killed with signal 13
6 Halted 0 ms 0 KB -