답안 #642647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642647 2022-09-20T10:02:06 Z SlavicG Password (RMI18_password) C++17
80 / 100
822 ms 556 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);
        string ff = ans;
        string bruh = "";
        for(int i = 0; i <= sz(ff); ++i) {
            int lol = 0;
            for(int j = 0; j < cnt; ++j) {
                bruh += c;
                string paiu = bruh;
                for(int k = i; k < sz(ff); ++k) paiu += ff[k];
                if(query(paiu) == sz(paiu)) {
                    ++lol;
                } else {
                    bruh.pop_back();
                    break;
                }
            }
            cnt -= lol;
            if(i < sz(ff)) bruh += ff[i];
        }
        ans = bruh;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 3 ms 208 KB Guessed the password with 187 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 48 queries.
2 Correct 1 ms 208 KB Guessed the password with 93 queries.
3 Correct 2 ms 208 KB Guessed the password with 91 queries.
4 Correct 2 ms 300 KB Guessed the password with 179 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 332 KB Guessed the password with 3133 queries.
2 Correct 127 ms 428 KB Guessed the password with 9153 queries.
3 Correct 66 ms 344 KB Guessed the password with 5201 queries.
4 Correct 135 ms 464 KB Guessed the password with 13851 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 3 ms 208 KB Guessed the password with 187 queries.
3 Correct 1 ms 208 KB Guessed the password with 48 queries.
4 Correct 1 ms 208 KB Guessed the password with 93 queries.
5 Correct 2 ms 208 KB Guessed the password with 91 queries.
6 Correct 2 ms 300 KB Guessed the password with 179 queries.
7 Correct 38 ms 332 KB Guessed the password with 3133 queries.
8 Correct 127 ms 428 KB Guessed the password with 9153 queries.
9 Correct 66 ms 344 KB Guessed the password with 5201 queries.
10 Correct 135 ms 464 KB Guessed the password with 13851 queries.
11 Correct 103 ms 476 KB Guessed the password with 9347 queries.
12 Correct 87 ms 556 KB Guessed the password with 9404 queries.
13 Correct 244 ms 444 KB Guessed the password with 17813 queries.
14 Correct 269 ms 432 KB Guessed the password with 18089 queries.
15 Correct 198 ms 360 KB Guessed the password with 14445 queries.
16 Correct 215 ms 356 KB Guessed the password with 14324 queries.
17 Correct 165 ms 452 KB Guessed the password with 12187 queries.
18 Correct 138 ms 424 KB Guessed the password with 12216 queries.
19 Correct 155 ms 480 KB Guessed the password with 10933 queries.
20 Correct 110 ms 304 KB Guessed the password with 11169 queries.
21 Correct 235 ms 464 KB Guessed the password with 15075 queries.
22 Correct 241 ms 360 KB Guessed the password with 14999 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Guessed the password with 76 queries.
2 Correct 3 ms 208 KB Guessed the password with 187 queries.
3 Correct 1 ms 208 KB Guessed the password with 48 queries.
4 Correct 1 ms 208 KB Guessed the password with 93 queries.
5 Correct 2 ms 208 KB Guessed the password with 91 queries.
6 Correct 2 ms 300 KB Guessed the password with 179 queries.
7 Correct 38 ms 332 KB Guessed the password with 3133 queries.
8 Correct 127 ms 428 KB Guessed the password with 9153 queries.
9 Correct 66 ms 344 KB Guessed the password with 5201 queries.
10 Correct 135 ms 464 KB Guessed the password with 13851 queries.
11 Correct 103 ms 476 KB Guessed the password with 9347 queries.
12 Correct 87 ms 556 KB Guessed the password with 9404 queries.
13 Correct 244 ms 444 KB Guessed the password with 17813 queries.
14 Correct 269 ms 432 KB Guessed the password with 18089 queries.
15 Correct 198 ms 360 KB Guessed the password with 14445 queries.
16 Correct 215 ms 356 KB Guessed the password with 14324 queries.
17 Correct 165 ms 452 KB Guessed the password with 12187 queries.
18 Correct 138 ms 424 KB Guessed the password with 12216 queries.
19 Correct 155 ms 480 KB Guessed the password with 10933 queries.
20 Correct 110 ms 304 KB Guessed the password with 11169 queries.
21 Correct 235 ms 464 KB Guessed the password with 15075 queries.
22 Correct 241 ms 360 KB Guessed the password with 14999 queries.
23 Incorrect 822 ms 524 KB Could not guess the password with 50000 queries.
24 Halted 0 ms 0 KB -