Submission #251436

# Submission time Handle Problem Language Result Execution time Memory
251436 2020-07-21T09:13:41 Z lyc Password (RMI18_password) C++14
100 / 100
317 ms 688 KB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " :: ";
#define _ << " " <<
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define SZ(x) ((int)(x).size())

int query(string Q);

string solve(vector<string>& vec, int l, int r) {
	if (l == r) return vec[l];
	
	int m = (l+r)>>1;
	string x = solve(vec,l,m), y = solve(vec,m+1,r);
	
	string S = "";
	int i, j;
	for (i = 0, j = 0; i < SZ(x) && j < SZ(y);) {
		string T = S + y[j] + x.substr(i);
		int q = query(T);
		if (q == SZ(T)) S += y[j++];
		else S += x[i++];
	}
	if (i < SZ(x)) S += x.substr(i);
	if (j < SZ(y)) S += y.substr(j);
	return S;
}

string guess(int N, int S) {
	vector<string> vec;
	FOR(i,0,S-1){
		string s(N,'a'+i);
		int freq = query(s);
		vec.push_back(string(freq,'a'+i));
	}
	
	return solve(vec,0,SZ(vec)-1);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Guessed the password with 60 queries.
2 Correct 1 ms 256 KB Guessed the password with 100 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Guessed the password with 48 queries.
2 Correct 2 ms 256 KB Guessed the password with 116 queries.
3 Correct 2 ms 256 KB Guessed the password with 91 queries.
4 Correct 3 ms 256 KB Guessed the password with 198 queries.
# Verdict Execution time Memory Grader output
1 Correct 34 ms 376 KB Guessed the password with 3455 queries.
2 Correct 70 ms 376 KB Guessed the password with 5024 queries.
3 Correct 65 ms 504 KB Guessed the password with 6353 queries.
4 Correct 93 ms 376 KB Guessed the password with 8694 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Guessed the password with 60 queries.
2 Correct 1 ms 256 KB Guessed the password with 100 queries.
3 Correct 1 ms 256 KB Guessed the password with 48 queries.
4 Correct 2 ms 256 KB Guessed the password with 116 queries.
5 Correct 2 ms 256 KB Guessed the password with 91 queries.
6 Correct 3 ms 256 KB Guessed the password with 198 queries.
7 Correct 34 ms 376 KB Guessed the password with 3455 queries.
8 Correct 70 ms 376 KB Guessed the password with 5024 queries.
9 Correct 65 ms 504 KB Guessed the password with 6353 queries.
10 Correct 93 ms 376 KB Guessed the password with 8694 queries.
11 Correct 130 ms 636 KB Guessed the password with 13637 queries.
12 Correct 160 ms 384 KB Guessed the password with 12460 queries.
13 Correct 198 ms 384 KB Guessed the password with 14391 queries.
14 Correct 183 ms 376 KB Guessed the password with 13938 queries.
15 Correct 156 ms 504 KB Guessed the password with 15072 queries.
16 Correct 179 ms 384 KB Guessed the password with 14153 queries.
17 Correct 140 ms 636 KB Guessed the password with 16053 queries.
18 Correct 107 ms 504 KB Guessed the password with 15190 queries.
19 Correct 202 ms 392 KB Guessed the password with 16409 queries.
20 Correct 151 ms 504 KB Guessed the password with 14248 queries.
21 Correct 205 ms 540 KB Guessed the password with 16848 queries.
22 Correct 192 ms 632 KB Guessed the password with 15316 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Guessed the password with 60 queries.
2 Correct 1 ms 256 KB Guessed the password with 100 queries.
3 Correct 1 ms 256 KB Guessed the password with 48 queries.
4 Correct 2 ms 256 KB Guessed the password with 116 queries.
5 Correct 2 ms 256 KB Guessed the password with 91 queries.
6 Correct 3 ms 256 KB Guessed the password with 198 queries.
7 Correct 34 ms 376 KB Guessed the password with 3455 queries.
8 Correct 70 ms 376 KB Guessed the password with 5024 queries.
9 Correct 65 ms 504 KB Guessed the password with 6353 queries.
10 Correct 93 ms 376 KB Guessed the password with 8694 queries.
11 Correct 130 ms 636 KB Guessed the password with 13637 queries.
12 Correct 160 ms 384 KB Guessed the password with 12460 queries.
13 Correct 198 ms 384 KB Guessed the password with 14391 queries.
14 Correct 183 ms 376 KB Guessed the password with 13938 queries.
15 Correct 156 ms 504 KB Guessed the password with 15072 queries.
16 Correct 179 ms 384 KB Guessed the password with 14153 queries.
17 Correct 140 ms 636 KB Guessed the password with 16053 queries.
18 Correct 107 ms 504 KB Guessed the password with 15190 queries.
19 Correct 202 ms 392 KB Guessed the password with 16409 queries.
20 Correct 151 ms 504 KB Guessed the password with 14248 queries.
21 Correct 205 ms 540 KB Guessed the password with 16848 queries.
22 Correct 192 ms 632 KB Guessed the password with 15316 queries.
23 Correct 247 ms 568 KB Guessed the password with 23613 queries.
24 Correct 207 ms 612 KB Guessed the password with 22227 queries.
25 Correct 240 ms 688 KB Guessed the password with 23795 queries.
26 Correct 317 ms 476 KB Guessed the password with 23333 queries.
27 Correct 316 ms 588 KB Guessed the password with 23764 queries.
28 Correct 249 ms 548 KB Guessed the password with 23044 queries.
29 Correct 273 ms 416 KB Guessed the password with 23848 queries.
30 Correct 244 ms 624 KB Guessed the password with 22507 queries.