답안 #642633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642633 2022-09-20T09:47:12 Z SlavicG Password (RMI18_password) C++17
10 / 100
3 ms 432 KB
#include "bits/stdc++.h"
using namespace std;
int query(string str);

#define sz(a) (int)a.size()

string guess(int n, int s) {
    vector<pair<int, char>> v;
    for(int f = 0; f < s; ++f) {
        char c = char('a' + f);
        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());
    assert(sz(ans) > 0);
    if(!sz(v)) return ans;

    for(auto noo: v) {
        char c = noo.second;
        int cnt = noo.first;
        vector<int> add(sz(ans) + 5, 0);
        for(int i = 0; i <= sz(ans); ++i) {
            string bruh = "";
            for(int j = 0; j < i; ++j) bruh += ans[j];
            for(int j = 0; j < cnt; ++j) {
                bruh += c;
                string rem = bruh;
                for(int j = i; j < sz(ans); ++j) bruh += ans[j];
                int qr = query(bruh);
                if(qr - sz(ans) == 1) {
                    ans = bruh;
                    ++add[i];
                }
                bruh = rem;
            }

            cnt -= add[i];
            assert(cnt >= 0);
            if(cnt <= 0) break;
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 2 ms 208 KB Guessed the password with 187 queries.
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 432 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 2 ms 208 KB Guessed the password with 187 queries.
3 Runtime error 1 ms 208 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 2 ms 208 KB Guessed the password with 187 queries.
3 Runtime error 1 ms 208 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -