답안 #709355

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709355 2023-03-13T13:14:59 Z maomao90 Password (RMI18_password) C++17
0 / 100
3 ms 464 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];

string dnc(int l, int r) {
    if (l == r) {
        return string(occ[l], 'a' + l);
    }
    int m = l + r >> 1;
    string sl = dnc(l, m), sr = dnc(m + 1, r);
    string str = sl;
    int ptr = 0;
    REP (i, 0, SZ(sr)) {
        str.insert(ptr, 1, sr[i]);
        while (query(str) != SZ(str)) {
            str.erase(ptr, 1);
            ptr++;
        }
        ptr++;
    }
    return str;
}

string guess(int n, int s) {
    REP (c, 0, s) {
        string str(n, 'a' + c);
        occ[c] = query(str);
    }
    string ans = dnc(0, s - 1);
    return ans;
}

Compilation message

password.cpp: In function 'std::string dnc(int, int)':
password.cpp:46:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |     int m = l + r >> 1;
      |             ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Returned early from guess() after 46 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 39 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Returned early from guess() after 46 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Returned early from guess() after 46 queries.
2 Halted 0 ms 0 KB -