답안 #757414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757414 2023-06-13T07:15:31 Z drdilyor Vim (BOI13_vim) C++17
11.1111 / 100
2000 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int inf = 1e9;

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int n;
    string t;
    cin >> n >> t;
    vector<int> e;
    string s;
    for (char c : t) {
        if (c != 'e') {
            s += c;
            e.push_back(0);
        } else {
            e.back()++;
        }
    }
    n = s.size();

    auto sum =[&](int l, int r) {
        ll s = 0;
        for (;l <= r; l++)
            s += e[l];
        return s;
    };
    vector memo(n, vector(n, -1));
    auto dp = [&](auto& dp, int i, int ne)->int {
        if (ne == n) return 0;
        int& res = memo[i][ne];
        if (res!=-1) return res;
        res = inf;
        set<char> seen;
        for (int j = i+1; j < n; j++) {
            if (seen.count(s[j])) continue;
            seen.insert(s[j]);
            int nne = j;
            while (nne < n && e[nne] == 0) nne++;
            int dist = j - ne;
            int ec = sum(ne, j-1);
            res = min(res, dp(dp, ne, nne) + max(0, dist) + max(0, ec * 2 - 1) + 2);
        }
        //cout << i << ' ' << ne << ' ' << res << '\n';
        return res;
    };

    int ne = 0;
    while (ne < n && e[ne] == 0) ne++;
    cout << dp(dp, 0, ne) << '\n';
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 596 KB Output is correct
2 Incorrect 44 ms 692 KB Output isn't correct
3 Incorrect 16 ms 600 KB Output isn't correct
4 Incorrect 68 ms 596 KB Output isn't correct
5 Correct 78 ms 612 KB Output is correct
6 Incorrect 141 ms 692 KB Output isn't correct
7 Incorrect 105 ms 724 KB Output isn't correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Correct 1 ms 272 KB Output is correct
10 Incorrect 1 ms 212 KB Output isn't correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 42 ms 580 KB Output is correct
14 Incorrect 58 ms 596 KB Output isn't correct
15 Incorrect 14 ms 596 KB Output isn't correct
16 Incorrect 47 ms 668 KB Output isn't correct
17 Incorrect 73 ms 824 KB Output isn't correct
18 Incorrect 53 ms 604 KB Output isn't correct
19 Incorrect 43 ms 468 KB Output isn't correct
20 Correct 53 ms 556 KB Output is correct
21 Incorrect 70 ms 620 KB Output isn't correct
22 Correct 75 ms 608 KB Output is correct
23 Incorrect 19 ms 960 KB Output isn't correct
24 Incorrect 38 ms 724 KB Output isn't correct
25 Incorrect 38 ms 788 KB Output isn't correct
26 Incorrect 48 ms 808 KB Output isn't correct
27 Incorrect 104 ms 724 KB Output isn't correct
28 Incorrect 150 ms 692 KB Output isn't correct
29 Incorrect 149 ms 736 KB Output isn't correct
30 Incorrect 37 ms 852 KB Output isn't correct
31 Incorrect 44 ms 784 KB Output isn't correct
32 Incorrect 46 ms 880 KB Output isn't correct
33 Incorrect 50 ms 972 KB Output isn't correct
34 Incorrect 80 ms 672 KB Output isn't correct
35 Incorrect 102 ms 620 KB Output isn't correct
36 Incorrect 101 ms 724 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2084 ms 14420 KB Time limit exceeded
2 Execution timed out 2033 ms 28756 KB Time limit exceeded
3 Execution timed out 2081 ms 7636 KB Time limit exceeded
4 Execution timed out 2072 ms 14420 KB Time limit exceeded
5 Execution timed out 2050 ms 31132 KB Time limit exceeded
6 Execution timed out 2064 ms 52412 KB Time limit exceeded
7 Execution timed out 2075 ms 22100 KB Time limit exceeded
8 Execution timed out 2085 ms 22484 KB Time limit exceeded
9 Execution timed out 2081 ms 28756 KB Time limit exceeded
10 Execution timed out 2080 ms 31828 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Runtime error 198 ms 524288 KB Execution killed with signal 9
2 Runtime error 208 ms 524288 KB Execution killed with signal 9
3 Runtime error 197 ms 524288 KB Execution killed with signal 9
4 Runtime error 192 ms 524288 KB Execution killed with signal 9
5 Runtime error 204 ms 524288 KB Execution killed with signal 9
6 Runtime error 191 ms 524288 KB Execution killed with signal 9
7 Runtime error 200 ms 524288 KB Execution killed with signal 9
8 Runtime error 185 ms 524288 KB Execution killed with signal 9
9 Runtime error 198 ms 524288 KB Execution killed with signal 9
10 Runtime error 198 ms 524288 KB Execution killed with signal 9
11 Runtime error 200 ms 524288 KB Execution killed with signal 9
12 Runtime error 202 ms 524288 KB Execution killed with signal 9
13 Runtime error 191 ms 524288 KB Execution killed with signal 9
14 Runtime error 187 ms 524288 KB Execution killed with signal 9
15 Runtime error 210 ms 524288 KB Execution killed with signal 9
16 Runtime error 201 ms 524288 KB Execution killed with signal 9
17 Runtime error 195 ms 524288 KB Execution killed with signal 9
18 Runtime error 209 ms 524288 KB Execution killed with signal 9
19 Runtime error 199 ms 524288 KB Execution killed with signal 9
20 Runtime error 201 ms 524288 KB Execution killed with signal 9