Submission #755952

#TimeUsernameProblemLanguageResultExecution timeMemory
755952MohamedFaresNebiliPassword (RMI18_password)C++14
80 / 100
1371 ms444 KiB
#include <bits/stdc++.h> using namespace std; int query(string str); string guess(int n, int s) { string S(n, 'a'); int freq[s]{0}; vector<pair<int, int>> v; for(int l = 0; l < s; l++) { for(int i = 0; i < n; i++) S[i] = char('a' + l); freq[l] = query(S); v.push_back({freq[l], l}); } sort(v.begin(), v.end()); S = ""; for(int l = 0; l < v[0].first; l++) S += char('a' + v[0].second); for(int _ = 1; _ < s; _++) { int l = v[_].second; for(int i = 0, last = 0; i < freq[l]; i++) { for(;; last++) { string str = ""; for(int e = 0; e < last; e++) str.push_back(S[e]); str.push_back(char('a' + l)); for(int e = last; e < S.size(); e++) str.push_back(S[e]); if(query(str) == str.size()) { S = str; last++; break; } } } } return S; }

Compilation message (stderr)

password.cpp: In function 'std::string guess(int, int)':
password.cpp:28:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                         for(int e = last; e < S.size(); e++)
      |                                           ~~^~~~~~~~~~
password.cpp:30:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |                         if(query(str) == str.size()) {
      |                            ~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...