Submission #755898

#TimeUsernameProblemLanguageResultExecution timeMemory
755898MohamedFaresNebiliPassword (RMI18_password)C++14
30 / 100
600 ms288 KiB
#include <bits/stdc++.h>

        using namespace std;

        string st; int k;
        int query(string str);

        string guess(int n, int s) {
            string S(n, 'a');
            int freq[s]{0};
            for(int l = 0; l < s; l++) {
                for(int i = 0; i < n; i++)
                    S[i] = char('a' + l);
                freq[l] = query(S);
            }
            S = "";
            for(int l = 0; l < s; l++) {
                for(int i = 0, last = 0; i < freq[l]; i++) {
                    for(int j = last;; j++) {
                        string str = "";
                        for(int e = 0; e < j; e++) str.push_back(S[e]);
                        str.push_back(char('a' + l));
                        for(int e = j; 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:23:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |                         for(int e = j; e < S.size(); e++)
      |                                        ~~^~~~~~~~~~
password.cpp:25:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |                         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...