답안 #757390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757390 2023-06-13T06:45:56 Z drdilyor Vim (BOI13_vim) C++17
1.38889 / 100
429 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 s;
    cin >> n >> s;

    vector memo(n, vector(n, -1));
    auto dp = [&](auto& dp, int l, int ne)->int {
        if (ne == n) return 0;
        if (memo[l][ne] !=-1) return memo[l][ne];
        vector seen(10, 0);
        int res = inf;
        int cnt = 0;
        for (int r = l+1; r < n; r++) {
            if (s[r] == 'e') {
                if (r >= ne) cnt++;
                continue;
            }
            if (seen[s[r] % 10]) continue;
            seen[s[r] % 10] = 1;
            if (cnt == 0) res = min(res, dp(dp, r, ne) + 2);
            else {
                int nne = r+1;
                while (nne <n && s[nne] != 'e') nne++;
                int cn = 0;
                for (int i = ne; i < n; i++)
                    if (s[i] == 'e') cn++;
                    else break;
                res = min(res, dp(dp, ne, nne) + 2 + (r - (ne + cn-1)) + cnt*2 - cn);
            }
        }
        return memo[l][ne] = res;
    };

    int ne = find(s.begin(), s.end(), 'e') - s.begin();
    cout << dp(dp, 0, ne)-1;
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1364 KB Output isn't correct
2 Incorrect 3 ms 1088 KB Output isn't correct
3 Incorrect 3 ms 980 KB Output isn't correct
4 Incorrect 4 ms 980 KB Output isn't correct
5 Incorrect 4 ms 980 KB Output isn't correct
6 Incorrect 5 ms 1364 KB Output isn't correct
7 Incorrect 5 ms 1340 KB Output isn't correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Correct 0 ms 316 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Incorrect 4 ms 1376 KB Output isn't correct
14 Incorrect 3 ms 1108 KB Output isn't correct
15 Incorrect 3 ms 980 KB Output isn't correct
16 Incorrect 3 ms 1108 KB Output isn't correct
17 Incorrect 4 ms 1236 KB Output isn't correct
18 Incorrect 3 ms 956 KB Output isn't correct
19 Incorrect 3 ms 852 KB Output isn't correct
20 Incorrect 3 ms 852 KB Output isn't correct
21 Incorrect 4 ms 980 KB Output isn't correct
22 Incorrect 4 ms 980 KB Output isn't correct
23 Incorrect 3 ms 1352 KB Output isn't correct
24 Incorrect 3 ms 1108 KB Output isn't correct
25 Incorrect 3 ms 1088 KB Output isn't correct
26 Incorrect 3 ms 1236 KB Output isn't correct
27 Incorrect 5 ms 1236 KB Output isn't correct
28 Incorrect 5 ms 1304 KB Output isn't correct
29 Incorrect 4 ms 1364 KB Output isn't correct
30 Incorrect 3 ms 1236 KB Output isn't correct
31 Incorrect 3 ms 1108 KB Output isn't correct
32 Incorrect 4 ms 1216 KB Output isn't correct
33 Incorrect 3 ms 1216 KB Output isn't correct
34 Incorrect 4 ms 1088 KB Output isn't correct
35 Incorrect 5 ms 1108 KB Output isn't correct
36 Incorrect 5 ms 1364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 429 ms 96528 KB Output isn't correct
2 Incorrect 386 ms 99196 KB Output isn't correct
3 Incorrect 133 ms 31564 KB Output isn't correct
4 Incorrect 414 ms 96404 KB Output isn't correct
5 Incorrect 413 ms 96652 KB Output isn't correct
6 Incorrect 374 ms 98756 KB Output isn't correct
7 Incorrect 415 ms 97652 KB Output isn't correct
8 Incorrect 424 ms 95240 KB Output isn't correct
9 Incorrect 386 ms 99196 KB Output isn't correct
10 Incorrect 392 ms 99192 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 237 ms 524288 KB Execution killed with signal 9
2 Runtime error 217 ms 524288 KB Execution killed with signal 9
3 Runtime error 207 ms 524288 KB Execution killed with signal 9
4 Runtime error 203 ms 524288 KB Execution killed with signal 9
5 Runtime error 209 ms 524288 KB Execution killed with signal 9
6 Runtime error 226 ms 524288 KB Execution killed with signal 9
7 Runtime error 213 ms 524288 KB Execution killed with signal 9
8 Runtime error 220 ms 524288 KB Execution killed with signal 9
9 Runtime error 215 ms 524288 KB Execution killed with signal 9
10 Runtime error 210 ms 524288 KB Execution killed with signal 9
11 Runtime error 210 ms 524288 KB Execution killed with signal 9
12 Runtime error 211 ms 524288 KB Execution killed with signal 9
13 Runtime error 206 ms 524288 KB Execution killed with signal 9
14 Runtime error 211 ms 524288 KB Execution killed with signal 9
15 Runtime error 212 ms 524288 KB Execution killed with signal 9
16 Runtime error 214 ms 524288 KB Execution killed with signal 9
17 Runtime error 210 ms 524288 KB Execution killed with signal 9
18 Runtime error 207 ms 524288 KB Execution killed with signal 9
19 Runtime error 216 ms 524288 KB Execution killed with signal 9
20 Runtime error 199 ms 524288 KB Execution killed with signal 9