답안 #201059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201059 2020-02-09T09:04:46 Z Atill83 Password (RMI18_password) C++14
0 / 100
12 ms 376 KB
#include<bits/stdc++.h>
using namespace std;

int query(string q); // 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()){
        ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Token "123" doesn't correspond to pattern "[a-o]{1,15}"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 248 KB Token "123" doesn't correspond to pattern "[a-b]{1,50}"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 376 KB Token "123" doesn't correspond to pattern "[a-l]{1,1000}"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Token "123" doesn't correspond to pattern "[a-o]{1,15}"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Token "123" doesn't correspond to pattern "[a-o]{1,15}"
2 Halted 0 ms 0 KB -