답안 #394232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394232 2021-04-26T07:58:25 Z jsannemo Password (RMI18_password) C++14
80 / 100
659 ms 820 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int query(string q);

vector<int> seen(26);
string alpha;

string go(const string& pre, int N, int S) {
	if (S < 0) return "";
	random_shuffle(alpha.begin(), alpha.begin() + S + 1);


	string q = pre + string(N - sz(pre), alpha[S]);
	int cnt = query(q) - seen[alpha[S] - 'a'] - sz(pre);

	string res;
	for (int i = cnt; i >= 0; --i) {
		string npre = pre;
		rep(j,0,i) npre.push_back(alpha[S]);

		if (i != cnt) {
			res.insert(res.begin(), alpha[S]);
			seen[alpha[S] - 'a']++;
		}
		res = go(npre, N, S - 1) + res;
	}

	return res;
}

string guess(int N, int S) {
	rep(i,0,S) alpha.push_back('a' + i);
	return go("", N, S - 1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 200 KB Guessed the password with 131 queries.
2 Correct 4 ms 300 KB Guessed the password with 305 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Guessed the password with 29 queries.
2 Correct 1 ms 200 KB Guessed the password with 36 queries.
3 Correct 2 ms 200 KB Guessed the password with 86 queries.
4 Correct 2 ms 292 KB Guessed the password with 119 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 332 KB Guessed the password with 5426 queries.
2 Correct 105 ms 344 KB Guessed the password with 9456 queries.
3 Correct 128 ms 376 KB Guessed the password with 14220 queries.
4 Correct 185 ms 384 KB Guessed the password with 18343 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 200 KB Guessed the password with 131 queries.
2 Correct 4 ms 300 KB Guessed the password with 305 queries.
3 Correct 0 ms 200 KB Guessed the password with 29 queries.
4 Correct 1 ms 200 KB Guessed the password with 36 queries.
5 Correct 2 ms 200 KB Guessed the password with 86 queries.
6 Correct 2 ms 292 KB Guessed the password with 119 queries.
7 Correct 85 ms 332 KB Guessed the password with 5426 queries.
8 Correct 105 ms 344 KB Guessed the password with 9456 queries.
9 Correct 128 ms 376 KB Guessed the password with 14220 queries.
10 Correct 185 ms 384 KB Guessed the password with 18343 queries.
11 Correct 511 ms 552 KB Guessed the password with 33659 queries.
12 Correct 356 ms 584 KB Guessed the password with 32903 queries.
13 Correct 460 ms 640 KB Guessed the password with 38641 queries.
14 Correct 424 ms 700 KB Guessed the password with 38302 queries.
15 Correct 507 ms 736 KB Guessed the password with 39050 queries.
16 Correct 369 ms 740 KB Guessed the password with 40569 queries.
17 Correct 607 ms 784 KB Guessed the password with 41515 queries.
18 Correct 534 ms 724 KB Guessed the password with 43358 queries.
19 Correct 421 ms 676 KB Guessed the password with 40755 queries.
20 Correct 372 ms 724 KB Guessed the password with 40516 queries.
21 Correct 520 ms 704 KB Guessed the password with 44587 queries.
22 Correct 574 ms 784 KB Guessed the password with 45174 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 200 KB Guessed the password with 131 queries.
2 Correct 4 ms 300 KB Guessed the password with 305 queries.
3 Correct 0 ms 200 KB Guessed the password with 29 queries.
4 Correct 1 ms 200 KB Guessed the password with 36 queries.
5 Correct 2 ms 200 KB Guessed the password with 86 queries.
6 Correct 2 ms 292 KB Guessed the password with 119 queries.
7 Correct 85 ms 332 KB Guessed the password with 5426 queries.
8 Correct 105 ms 344 KB Guessed the password with 9456 queries.
9 Correct 128 ms 376 KB Guessed the password with 14220 queries.
10 Correct 185 ms 384 KB Guessed the password with 18343 queries.
11 Correct 511 ms 552 KB Guessed the password with 33659 queries.
12 Correct 356 ms 584 KB Guessed the password with 32903 queries.
13 Correct 460 ms 640 KB Guessed the password with 38641 queries.
14 Correct 424 ms 700 KB Guessed the password with 38302 queries.
15 Correct 507 ms 736 KB Guessed the password with 39050 queries.
16 Correct 369 ms 740 KB Guessed the password with 40569 queries.
17 Correct 607 ms 784 KB Guessed the password with 41515 queries.
18 Correct 534 ms 724 KB Guessed the password with 43358 queries.
19 Correct 421 ms 676 KB Guessed the password with 40755 queries.
20 Correct 372 ms 724 KB Guessed the password with 40516 queries.
21 Correct 520 ms 704 KB Guessed the password with 44587 queries.
22 Correct 574 ms 784 KB Guessed the password with 45174 queries.
23 Execution timed out 659 ms 820 KB Time limit exceeded (wall clock)
24 Halted 0 ms 0 KB -