Submission #973455

# Submission time Handle Problem Language Result Execution time Memory
973455 2024-05-02T02:45:37 Z pcc Password (RMI18_password) C++17
50 / 100
260 ms 1204 KB
#include <bits/stdc++.h>
using namespace std;

int query(string s);

string guess(int N,int S){
	string tans;
	vector<int> cnt(S,0);
	for(int i = 0;i<S;i++){
		string tmp(N,'a'+i);
		cnt[i] = query(tmp);
	}
	for(int i = 0;i<N;i++){
		char tar;
		for(int j = 0;j<S;j++){
			if(cnt[j]){
				tar = 'a'+j;
				break;
			}
		}
		for(int j = tar-'a'+1;j<S;j++){
			if(!cnt[j])continue;
			string tmp = tans+tar+string(cnt[j],'a'+j);
			if(query(tmp) != tmp.size())tar = 'a'+j;
		}
		tans += tar;
		cnt[tar-'a']--;
	}
	return tans;
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |    if(query(tmp) != tmp.size())tar = 'a'+j;
      |       ~~~~~~~~~~~^~~~~~~~~~~~~
password.cpp:21:15: warning: 'tar' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |   for(int j = tar-'a'+1;j<S;j++){
      |               ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Guessed the password with 121 queries.
2 Correct 2 ms 344 KB Guessed the password with 277 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Guessed the password with 49 queries.
2 Correct 1 ms 344 KB Guessed the password with 133 queries.
3 Correct 1 ms 344 KB Guessed the password with 169 queries.
4 Correct 2 ms 436 KB Guessed the password with 292 queries.
# Verdict Execution time Memory Grader output
1 Correct 45 ms 700 KB Guessed the password with 9609 queries.
2 Correct 87 ms 1192 KB Guessed the password with 17345 queries.
3 Correct 108 ms 948 KB Guessed the password with 21756 queries.
4 Correct 181 ms 704 KB Guessed the password with 36498 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Guessed the password with 121 queries.
2 Correct 2 ms 344 KB Guessed the password with 277 queries.
3 Correct 1 ms 344 KB Guessed the password with 49 queries.
4 Correct 1 ms 344 KB Guessed the password with 133 queries.
5 Correct 1 ms 344 KB Guessed the password with 169 queries.
6 Correct 2 ms 436 KB Guessed the password with 292 queries.
7 Correct 45 ms 700 KB Guessed the password with 9609 queries.
8 Correct 87 ms 1192 KB Guessed the password with 17345 queries.
9 Correct 108 ms 948 KB Guessed the password with 21756 queries.
10 Correct 181 ms 704 KB Guessed the password with 36498 queries.
11 Incorrect 260 ms 1204 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Guessed the password with 121 queries.
2 Correct 2 ms 344 KB Guessed the password with 277 queries.
3 Correct 1 ms 344 KB Guessed the password with 49 queries.
4 Correct 1 ms 344 KB Guessed the password with 133 queries.
5 Correct 1 ms 344 KB Guessed the password with 169 queries.
6 Correct 2 ms 436 KB Guessed the password with 292 queries.
7 Correct 45 ms 700 KB Guessed the password with 9609 queries.
8 Correct 87 ms 1192 KB Guessed the password with 17345 queries.
9 Correct 108 ms 948 KB Guessed the password with 21756 queries.
10 Correct 181 ms 704 KB Guessed the password with 36498 queries.
11 Incorrect 260 ms 1204 KB Could not guess the password with 50000 queries.
12 Halted 0 ms 0 KB -