Submission #709218

# Submission time Handle Problem Language Result Execution time Memory
709218 2023-03-13T08:39:18 Z maomao90 Password (RMI18_password) C++17
0 / 100
46 ms 336 KB
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 5005;

int query(string str);

int occ[30];
int pos[30][MAXN];
string guess(int n, int s) {
    REP (c, 0, s) {
        string str(n, 'a' + c);
        occ[c] = query(str);
    }
    vi id(s, 0);
    iota(ALL(id), 0);
    sort(ALL(id), [&] (int l, int r) {
            return occ[l] > occ[r];
            });
    REP (i, 0, s) {
        REP (j, 0, n) {
            pos[i][j] = 0;
        }
    }
    /*
    REP (li, 0, s) {
        int l = id[li];
        REP (ri, li + 1, s) {
            int r = id[ri];
            string str(n, 'a' + r);
            cerr << str << '\n';
            REP (i, 0, occ[l]) {
                str[n - i - 1] = 'a' + l;
            }
            int px = 0;
            RREP (i, occ[l], 1) {
                int x = query(str) - i;
                cerr << str << ' ' << x << '\n';
                pos[l][occ[l] - i] += x;
                REP (j, px, x) {
                    pos[r][j] += occ[l] - i;
                }
                px = x;
                str[n - i] = 'a' + r;
            }
        }
    }
    */
    REP (li, 0, s) {
        int l = id[li];
        REP (ri, l + 1, s) {
            int r = id[ri];
            int ptr = occ[r];
            auto make = [&] (int x, int y) {
                string s = "";
                REP (i, 0, x) {
                    s += l + 'a';
                }
                REP (i, 0, y) {
                    s += r + 'a';
                }
                return s;
            };
            REP (i, 1, occ[l] + 1) {
                while (ptr >= 1 && query(make(i, ptr)) != i + ptr) {
                    pos[r][occ[r] - ptr] += i - 1;
                    ptr--;
                }
                pos[l][i - 1] += occ[r] - ptr;
            }
            while (ptr >= 1) {
                pos[r][occ[r] - ptr] += occ[l];
                ptr--;
            }
        }
    }
    string ans(n, '?');
    REP (c, 0, s) {
        REP (i, 0, occ[c]) {
            ans[pos[c][i] + i] = 'a' + c;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Guessed the password with 121 queries.
2 Incorrect 3 ms 336 KB Token "uwlv?s?rbqf??m??cnk????" doesn't correspond to pattern "[a-w]{1,23}"
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Token "bbbbbbbbbbbbbbbbbbbbbbbbbb??a??a??a??a??a??a??a??a" doesn't correspond to pattern "[a-b]{1,50}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 312 KB Token "lkkllklllllllllllllkkkllllllkl...???????????????????????????????" doesn't correspond to pattern "[a-l]{1,1000}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Guessed the password with 121 queries.
2 Incorrect 3 ms 336 KB Token "uwlv?s?rbqf??m??cnk????" doesn't correspond to pattern "[a-w]{1,23}"
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Guessed the password with 121 queries.
2 Incorrect 3 ms 336 KB Token "uwlv?s?rbqf??m??cnk????" doesn't correspond to pattern "[a-w]{1,23}"
3 Halted 0 ms 0 KB -