Submission #464485

#TimeUsernameProblemLanguageResultExecution timeMemory
464485fuad27Password (RMI18_password)C++17
0 / 100
1 ms200 KiB
    #include <bits/stdc++.h>
//#include"grader.cpp"
    using namespace std;
    int query(string s);
    int f[30];
    string guess(int n, int s) {
        string ans;
        for (int i = 0; i < s; i++) {
            char c = 'a' + i;
            string q(n, c);
            f[i] = query(q);
        }
        int st = 0;
        for (int i = 0; i < s; i++) {
            if (f[i] > 0) {
                char c = i + 'a';
                for (int j = 1; j <= f[i]; i++) {
                    ans += c;
                }
                st = i + 1;
                break;
            }
        }
        int curlen = ans.length();
        for (int i = st; i < s; i++) {
            char c = i + 'a';
            string ch;
            ch += c;
            int pos = -1;
            string q;
            while (true) {
                if (f[i] == 0) break;
                if (pos == -1) {
                    q = ch + ans;
                } else {
                    q = ans.substr(0, pos + 1) + ch;
                    q += ans.substr(pos + 1, curlen - pos - 1);
                }
                if (query(q) == curlen + 1) {
                    ans = q;
                    curlen++;
                    pos++;
                    f[i]--;
                } else {
                    pos++;
                }
                if (pos >= curlen) break;
            }
        }
        return ans;
    }
#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...