Submission #201061

# Submission time Handle Problem Language Result Execution time Memory
201061 2020-02-09T09:09:06 Z Atill83 Password (RMI18_password) C++14
30 / 100
484 ms 380 KB
#include<bits/stdc++.h>
using namespace std;

int query(string str); // bu satiri silmeyin ve dokunmayin

string sifre;
int kac[30];
bool dnt[30];
string guess(int n,int s) { // bu fonksiyonu yazin
	for(int i = 0; i < s; i++){
		string sorgu;
		for(int j = 0; j < n; j++){
			sorgu += (char) ('a' + i);
		}
		kac[i] = query(sorgu);
	}
	string suan;
	
	for(int i = n - 1; i >= 0; i--){
		int cur = 0;
		int kr = 0;
		for(int k = 0; k < s; k++){
			if(kac[k] > kr){
				cur = k;
				kr = kac[k];
			}
		}
		while(true){
			int j = cur;
			//cout<<j<<" "<<suan<<endl;
			if(!kac[j]) continue;
			string sorgu;
			for(int k = 0; k < kac[j]; k++)
			 	sorgu += (char) ('a' + j);
			bool buson = 1;
			vector<int> a;
			for(int k = 0; k < s; k++){
				if(dnt[k] || k == j || kac[k] == 0) continue;
				a.push_back(k);
			}
			//shuffle(a.begin(), a.end(), gen);
			
			for(int k = 0; k < a.size(); k++){
				string other = sorgu + (char) ('a' + a[k]) + suan;
				//cout<<other<<endl;
				if(query(other) == other.length()){
					cur = a[k];
					buson = 0;
					dnt[j] = 1;
					break;
				}
			}
			if(buson){
				for(int l = 0; l < s; l++) dnt[l] = 0;
				suan = (char)(j + 'a') + suan;
				kac[j]--;
				break;
			}
		}
	}
	return suan;
}

Compilation message

password.cpp: In function 'std::__cxx11::string guess(int, int)':
password.cpp:43:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k = 0; k < a.size(); k++){
                   ~~^~~~~~~~~~
password.cpp:46:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(query(other) == other.length()){
        ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 248 KB Guessed the password with 155 queries.
2 Correct 8 ms 380 KB Guessed the password with 422 queries.
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Guessed the password with 47 queries.
2 Correct 6 ms 376 KB Guessed the password with 149 queries.
3 Correct 5 ms 376 KB Guessed the password with 17 queries.
4 Correct 9 ms 248 KB Guessed the password with 345 queries.
# Verdict Execution time Memory Grader output
1 Correct 149 ms 248 KB Guessed the password with 13605 queries.
2 Correct 278 ms 376 KB Guessed the password with 26744 queries.
3 Correct 323 ms 376 KB Guessed the password with 29960 queries.
4 Incorrect 484 ms 376 KB Could not guess the password with 50000 queries.
# Verdict Execution time Memory Grader output
1 Correct 7 ms 248 KB Guessed the password with 155 queries.
2 Correct 8 ms 380 KB Guessed the password with 422 queries.
3 Correct 6 ms 376 KB Guessed the password with 47 queries.
4 Correct 6 ms 376 KB Guessed the password with 149 queries.
5 Correct 5 ms 376 KB Guessed the password with 17 queries.
6 Correct 9 ms 248 KB Guessed the password with 345 queries.
7 Correct 149 ms 248 KB Guessed the password with 13605 queries.
8 Correct 278 ms 376 KB Guessed the password with 26744 queries.
9 Correct 323 ms 376 KB Guessed the password with 29960 queries.
10 Incorrect 484 ms 376 KB Could not guess the password with 50000 queries.
# Verdict Execution time Memory Grader output
1 Correct 7 ms 248 KB Guessed the password with 155 queries.
2 Correct 8 ms 380 KB Guessed the password with 422 queries.
3 Correct 6 ms 376 KB Guessed the password with 47 queries.
4 Correct 6 ms 376 KB Guessed the password with 149 queries.
5 Correct 5 ms 376 KB Guessed the password with 17 queries.
6 Correct 9 ms 248 KB Guessed the password with 345 queries.
7 Correct 149 ms 248 KB Guessed the password with 13605 queries.
8 Correct 278 ms 376 KB Guessed the password with 26744 queries.
9 Correct 323 ms 376 KB Guessed the password with 29960 queries.
10 Incorrect 484 ms 376 KB Could not guess the password with 50000 queries.