# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
108701 |
2019-05-01T05:30:25 Z |
ihdignite |
Vim (BOI13_vim) |
C++14 |
|
95 ms |
22840 KB |
#include <bits/stdc++.h>
using namespace std;
const int mxN=7e4;
int n, a1, t[mxN+1], m, dp1[mxN+1][10], dp2[mxN+1][10][10];
string s;
bool u[mxN];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> s;
for(int i=0, j=0; i<n; ++i) {
if(s[i]=='e') {
a1+=2;
j=1;
} else {
t[m]=s[i]-'a'-(s[i]>'e');
u[m++]=j;
j=0;
}
}
t[m]=9;
memset(dp2[0], 0x3f, sizeof(dp2[0]));
for(int i=0; i<10; ++i)
dp1[0][i]=t[0]==i?0:2;
auto a=[](bool b) {
return b?9*n:0;
};
for(int i=0; i<m; ++i) {
for(int j=0; j<10; ++j) {
dp1[i+1][j]=min({dp1[i][j]+a(j==t[i])+a(u[i]), dp1[i][t[i]]+2, dp2[i][t[i]][j]+a(j==t[i]), dp2[i][t[i]][t[i]]+2});
for(int k=0; k<10; ++k)
dp2[i+1][j][k]=min({dp1[i][j]+3+a(j==t[i]), dp1[i][t[i]]+5, dp2[i][j][k]+1+a(j==t[i])+a(k==t[i]), dp2[i][j][t[i]]+3+a(j==t[i]), dp2[i][t[i]][k]+3+a(k==t[i]), dp2[i][t[i]][t[i]]+5});
}
}
cout << a1+dp1[m][9]-2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
428 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
3 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
304 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
2 ms |
428 KB |
Output is correct |
15 |
Correct |
2 ms |
512 KB |
Output is correct |
16 |
Correct |
3 ms |
512 KB |
Output is correct |
17 |
Correct |
2 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
512 KB |
Output is correct |
22 |
Correct |
2 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
4 ms |
512 KB |
Output is correct |
25 |
Correct |
3 ms |
484 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
3 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
452 KB |
Output is correct |
30 |
Correct |
3 ms |
512 KB |
Output is correct |
31 |
Correct |
3 ms |
512 KB |
Output is correct |
32 |
Correct |
4 ms |
560 KB |
Output is correct |
33 |
Correct |
3 ms |
512 KB |
Output is correct |
34 |
Correct |
3 ms |
512 KB |
Output is correct |
35 |
Correct |
3 ms |
512 KB |
Output is correct |
36 |
Correct |
3 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1144 KB |
Output is correct |
2 |
Correct |
6 ms |
1536 KB |
Output is correct |
3 |
Correct |
4 ms |
896 KB |
Output is correct |
4 |
Correct |
5 ms |
1152 KB |
Output is correct |
5 |
Correct |
6 ms |
1664 KB |
Output is correct |
6 |
Correct |
7 ms |
1920 KB |
Output is correct |
7 |
Correct |
5 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1408 KB |
Output is correct |
9 |
Correct |
8 ms |
1536 KB |
Output is correct |
10 |
Correct |
8 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
19832 KB |
Output is correct |
2 |
Correct |
80 ms |
19156 KB |
Output is correct |
3 |
Correct |
74 ms |
20216 KB |
Output is correct |
4 |
Correct |
93 ms |
20472 KB |
Output is correct |
5 |
Correct |
69 ms |
22776 KB |
Output is correct |
6 |
Correct |
50 ms |
10488 KB |
Output is correct |
7 |
Correct |
65 ms |
17144 KB |
Output is correct |
8 |
Correct |
72 ms |
19908 KB |
Output is correct |
9 |
Correct |
48 ms |
14712 KB |
Output is correct |
10 |
Correct |
51 ms |
14072 KB |
Output is correct |
11 |
Correct |
72 ms |
20516 KB |
Output is correct |
12 |
Correct |
95 ms |
22840 KB |
Output is correct |
13 |
Correct |
72 ms |
22520 KB |
Output is correct |
14 |
Correct |
72 ms |
22136 KB |
Output is correct |
15 |
Correct |
64 ms |
18680 KB |
Output is correct |
16 |
Correct |
70 ms |
20216 KB |
Output is correct |
17 |
Correct |
70 ms |
20088 KB |
Output is correct |
18 |
Correct |
64 ms |
20216 KB |
Output is correct |
19 |
Correct |
56 ms |
19064 KB |
Output is correct |
20 |
Correct |
59 ms |
16220 KB |
Output is correct |