# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
895873 | 2023-12-31T02:38:55 Z | noompty | Vim (BOI13_vim) | C++17 | 26 ms | 75972 KB |
#include <iostream> #include <vector> #include <cstring> #include <algorithm> using namespace std; int n, sz, cnt, f[80005][15], g[80005][15][15], key[80005]; char s[80005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1, tmp = 0; i <= n; i++) { char c; cin >> c; if (c == 'e') { tmp = ++cnt; } else { key[++sz] = tmp; s[sz] = c - 'a'; tmp = 0; } } memset(f, 0x3f, sizeof f); memset(g, 0x3f, sizeof g); f[0][s[1]] = 0; for (int i = 1; i <= sz; i++) { for (int j = 0; j < 10; j++) { if (j != s[i]) { if (!key[i]) { f[i][j] = f[i - 1][j]; } f[i][j] = min(f[i][j], g[i - 1][s[i]][j]); } f[i][j] = min(f[i][j], min(f[i - 1][s[i]], g[i - 1][s[i]][s[i]]) + 2); for (int k = 0; k < 10; k++) { if (j != s[i] && k != s[i]) { g[i][j][k] = g[i - 1][j][k] + 1; } if (j != s[i]) { g[i][j][k] = min(g[i][j][k], min(f[i - 1][j], g[i - 1][j][s[i]]) + 3); } if (k != s[i]) { g[i][j][k] = min(g[i][j][k], g[i - 1][s[i]][k] + 3); } g[i][j][k] = min(g[i][j][k], min(f[i - 1][s[i]], g[i - 1][s[i]][s[i]]) + 5); } } } cout << f[sz][9] + (2 * cnt) - 2 << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 75612 KB | Output is correct |
2 | Correct | 9 ms | 75716 KB | Output is correct |
3 | Correct | 10 ms | 75612 KB | Output is correct |
4 | Correct | 9 ms | 75612 KB | Output is correct |
5 | Incorrect | 10 ms | 75612 KB | Output isn't correct |
6 | Correct | 10 ms | 75612 KB | Output is correct |
7 | Correct | 10 ms | 75728 KB | Output is correct |
8 | Correct | 10 ms | 75776 KB | Output is correct |
9 | Correct | 9 ms | 75612 KB | Output is correct |
10 | Correct | 10 ms | 75612 KB | Output is correct |
11 | Correct | 10 ms | 75612 KB | Output is correct |
12 | Correct | 9 ms | 75712 KB | Output is correct |
13 | Correct | 9 ms | 75612 KB | Output is correct |
14 | Correct | 9 ms | 75612 KB | Output is correct |
15 | Correct | 9 ms | 75612 KB | Output is correct |
16 | Correct | 10 ms | 75608 KB | Output is correct |
17 | Correct | 10 ms | 75740 KB | Output is correct |
18 | Incorrect | 10 ms | 75612 KB | Output isn't correct |
19 | Incorrect | 10 ms | 75796 KB | Output isn't correct |
20 | Correct | 9 ms | 75608 KB | Output is correct |
21 | Correct | 10 ms | 75612 KB | Output is correct |
22 | Incorrect | 9 ms | 75612 KB | Output isn't correct |
23 | Incorrect | 10 ms | 75612 KB | Output isn't correct |
24 | Incorrect | 9 ms | 75612 KB | Output isn't correct |
25 | Correct | 10 ms | 75608 KB | Output is correct |
26 | Correct | 9 ms | 75612 KB | Output is correct |
27 | Incorrect | 9 ms | 75612 KB | Output isn't correct |
28 | Correct | 9 ms | 75612 KB | Output is correct |
29 | Incorrect | 9 ms | 75612 KB | Output isn't correct |
30 | Correct | 9 ms | 75612 KB | Output is correct |
31 | Incorrect | 9 ms | 75612 KB | Output isn't correct |
32 | Correct | 9 ms | 75612 KB | Output is correct |
33 | Correct | 10 ms | 75612 KB | Output is correct |
34 | Correct | 9 ms | 75612 KB | Output is correct |
35 | Correct | 10 ms | 75764 KB | Output is correct |
36 | Correct | 10 ms | 75612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 75612 KB | Output is correct |
2 | Correct | 10 ms | 75612 KB | Output is correct |
3 | Correct | 10 ms | 75760 KB | Output is correct |
4 | Correct | 10 ms | 75612 KB | Output is correct |
5 | Correct | 11 ms | 75824 KB | Output is correct |
6 | Incorrect | 11 ms | 75612 KB | Output isn't correct |
7 | Correct | 10 ms | 75724 KB | Output is correct |
8 | Correct | 10 ms | 75612 KB | Output is correct |
9 | Correct | 10 ms | 75800 KB | Output is correct |
10 | Incorrect | 10 ms | 75612 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 75868 KB | Output isn't correct |
2 | Correct | 24 ms | 75864 KB | Output is correct |
3 | Correct | 24 ms | 75868 KB | Output is correct |
4 | Incorrect | 25 ms | 75868 KB | Output isn't correct |
5 | Correct | 26 ms | 75868 KB | Output is correct |
6 | Incorrect | 17 ms | 75864 KB | Output isn't correct |
7 | Correct | 22 ms | 75964 KB | Output is correct |
8 | Correct | 24 ms | 75868 KB | Output is correct |
9 | Correct | 21 ms | 75864 KB | Output is correct |
10 | Correct | 20 ms | 75868 KB | Output is correct |
11 | Incorrect | 24 ms | 75868 KB | Output isn't correct |
12 | Correct | 25 ms | 75868 KB | Output is correct |
13 | Correct | 26 ms | 75868 KB | Output is correct |
14 | Correct | 26 ms | 75972 KB | Output is correct |
15 | Incorrect | 23 ms | 75968 KB | Output isn't correct |
16 | Incorrect | 25 ms | 75948 KB | Output isn't correct |
17 | Incorrect | 24 ms | 75864 KB | Output isn't correct |
18 | Correct | 24 ms | 75868 KB | Output is correct |
19 | Correct | 23 ms | 75864 KB | Output is correct |
20 | Incorrect | 21 ms | 75868 KB | Output isn't correct |