Submission #286957

# Submission time Handle Problem Language Result Execution time Memory
286957 2020-08-31T07:54:46 Z crossing0ver Password (RMI18_password) C++17
30 / 100
436 ms 504 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;

int m;
string suf,pref;
int query(string str);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string guess(int n, int s) {
	string pref,P;
	vector<char> D;
	for (char i = 'a'; i < 'a' + s ; i++)
		D.pb(i);
	for (; pref.size() + suf.size() <= n; ) {
		int len = suf.size() + pref.size();
		char LAST = ((int)pref.size() ? pref.back() : 'a');
		int cur = len;
		for (int z = 1; z + pref.size() + suf.size() <= n;) {
			bool flag = 0;
			shuffle(D.begin(),D.end(),rng);
		for (char c : D) {
			P = pref + c;
			P += suf;
			int F = query(P);
			if (F > cur) {
				LAST = c;
				pref += c;
				cur = F;
				flag  = 1;
				break;
			}
		}
		if (flag == 0) break;
		}
		reverse(all(suf));
		if (pref.size())
		suf+=pref.back();
		reverse(all(suf));
		if (pref.size())
		pref.pop_back();
		if (pref.size() + suf.size() == n) {
			pref += suf;
			int Z = query(pref);
			return pref;
		}
	}
	pref += suf;
	int z = query(pref);
	return pref;
}
/*
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

}*/

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:20:34: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |  for (; pref.size() + suf.size() <= n; ) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
password.cpp:24:48: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   for (int z = 1; z + pref.size() + suf.size() <= n;) {
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
password.cpp:47:32: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |   if (pref.size() + suf.size() == n) {
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
password.cpp:49:8: warning: unused variable 'Z' [-Wunused-variable]
   49 |    int Z = query(pref);
      |        ^
password.cpp:22:8: warning: variable 'LAST' set but not used [-Wunused-but-set-variable]
   22 |   char LAST = ((int)pref.size() ? pref.back() : 'a');
      |        ^~~~
password.cpp:54:6: warning: unused variable 'z' [-Wunused-variable]
   54 |  int z = query(pref);
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Guessed the password with 266 queries.
2 Correct 9 ms 256 KB Guessed the password with 721 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Guessed the password with 156 queries.
2 Correct 3 ms 256 KB Guessed the password with 329 queries.
3 Correct 2 ms 256 KB Guessed the password with 221 queries.
4 Correct 5 ms 256 KB Guessed the password with 589 queries.
# Verdict Execution time Memory Grader output
1 Correct 158 ms 376 KB Guessed the password with 16584 queries.
2 Correct 287 ms 376 KB Guessed the password with 27490 queries.
3 Correct 415 ms 504 KB Guessed the password with 39182 queries.
4 Incorrect 436 ms 504 KB Could not guess the password with 50000 queries.
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Guessed the password with 266 queries.
2 Correct 9 ms 256 KB Guessed the password with 721 queries.
3 Correct 1 ms 256 KB Guessed the password with 156 queries.
4 Correct 3 ms 256 KB Guessed the password with 329 queries.
5 Correct 2 ms 256 KB Guessed the password with 221 queries.
6 Correct 5 ms 256 KB Guessed the password with 589 queries.
7 Correct 158 ms 376 KB Guessed the password with 16584 queries.
8 Correct 287 ms 376 KB Guessed the password with 27490 queries.
9 Correct 415 ms 504 KB Guessed the password with 39182 queries.
10 Incorrect 436 ms 504 KB Could not guess the password with 50000 queries.
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Guessed the password with 266 queries.
2 Correct 9 ms 256 KB Guessed the password with 721 queries.
3 Correct 1 ms 256 KB Guessed the password with 156 queries.
4 Correct 3 ms 256 KB Guessed the password with 329 queries.
5 Correct 2 ms 256 KB Guessed the password with 221 queries.
6 Correct 5 ms 256 KB Guessed the password with 589 queries.
7 Correct 158 ms 376 KB Guessed the password with 16584 queries.
8 Correct 287 ms 376 KB Guessed the password with 27490 queries.
9 Correct 415 ms 504 KB Guessed the password with 39182 queries.
10 Incorrect 436 ms 504 KB Could not guess the password with 50000 queries.