Submission #642614

# Submission time Handle Problem Language Result Execution time Memory
642614 2022-09-20T09:13:48 Z SlavicG Password (RMI18_password) C++17
0 / 100
3 ms 208 KB
#include "bits/stdc++.h"
using namespace std;
int query(string q);


string guess(int n, int s) {
    vector<pair<int, char>> v;
    for(char c = 'a'; c < (char)('a' + s); ++c) {
        string paiu = string(n, c);
        int x = query(paiu);
        if(x > 0) {
            v.push_back({x, c});
        }
    }
    assert(v.size() > 0);
    sort(v.begin(), v.end());
    string ans = string(v[0].first, v[0].second);

    v.erase(v.begin());
    for(auto x: v) {
        char c = x.second;
        int cnt = x.first;
        vector<int> add((int)ans.size() + 1, 0);
        for(int i = 0; i <= (int)ans.size() && cnt; ++i) {
            string bruh = "";
            for(int j = 0; j < i; ++j) bruh += ans[j];
            for(int j = 0; j < cnt; ++j) bruh += c;
            for(int j = i; j < (int)ans.size(); ++j) bruh += ans[j];
            int qr = query(bruh);
            add[i] = qr - (int)ans.size();
            cnt -= add[i];
        }
        string newans = "";
        for(int i = 0; i <= (int)ans.size(); ++i) {
            for(int j = 0; j < add[i]; ++j) newans += c;
            if(i < (int)ans.size()) newans += ans[i];
        }
        ans = newans;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Returned early from guess() after 8 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -