Submission #106134

# Submission time Handle Problem Language Result Execution time Memory
106134 2019-04-16T18:14:37 Z ihdignite Vim (BOI13_vim) C++14
23.6111 / 100
52 ms 6160 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN=7e4;
int n, ans=1e9, dp[mxN][10], nxt[mxN+1][10];
string s;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> s;
	fill(nxt[n], nxt[n]+10, n);
	for(int i=n-1; ~i; --i) {
		memcpy(nxt[i], nxt[i+1], 40);
		nxt[i][s[i]-'a']=i;
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[0][s[0]-'a']=0;
	int e=n-1;
	while(e&&s[e-1]^'e')
		--e;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<10; ++j) {
			if(j==4)
				continue;
			if(nxt[i][j]>=e)
				ans=min(dp[i][j], ans);
			int y=n;
			for(int k=0; k<10; ++k)
				if(k^4)
					y=min(nxt[nxt[nxt[i][j]][4]][k], y);
			for(int k=0; k<10; ++k) {
				if(k==4||nxt[i+1][k]>=n)
					continue;
				int x=min(nxt[i+1][k], y), a=nxt[i+1][k], nf=1;
				if(a<=nxt[i][j]) {
					a=nxt[a+1][k];
					++nf;
				}
				dp[x][k]=min(dp[i][j]+2*nf+max(a-nxt[nxt[i][j]][4], 0), dp[x][k]);
			}
		}
	}
	for(char c : s)
		ans+=c=='e';
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3072 KB Output is correct
2 Incorrect 5 ms 3072 KB Output isn't correct
3 Incorrect 4 ms 3072 KB Output isn't correct
4 Incorrect 5 ms 3072 KB Output isn't correct
5 Correct 5 ms 3072 KB Output is correct
6 Incorrect 4 ms 3072 KB Output isn't correct
7 Incorrect 4 ms 3072 KB Output isn't correct
8 Correct 4 ms 3072 KB Output is correct
9 Correct 5 ms 3072 KB Output is correct
10 Correct 5 ms 3072 KB Output is correct
11 Correct 4 ms 3072 KB Output is correct
12 Correct 5 ms 3072 KB Output is correct
13 Correct 5 ms 3072 KB Output is correct
14 Incorrect 5 ms 3072 KB Output isn't correct
15 Incorrect 5 ms 3072 KB Output isn't correct
16 Incorrect 5 ms 3072 KB Output isn't correct
17 Correct 5 ms 3072 KB Output is correct
18 Incorrect 5 ms 3072 KB Output isn't correct
19 Incorrect 5 ms 3072 KB Output isn't correct
20 Correct 5 ms 3072 KB Output is correct
21 Incorrect 6 ms 3072 KB Output isn't correct
22 Correct 5 ms 3072 KB Output is correct
23 Incorrect 5 ms 3072 KB Output isn't correct
24 Incorrect 5 ms 3072 KB Output isn't correct
25 Correct 5 ms 3072 KB Output is correct
26 Correct 6 ms 3072 KB Output is correct
27 Correct 6 ms 3200 KB Output is correct
28 Incorrect 5 ms 3072 KB Output isn't correct
29 Incorrect 5 ms 3072 KB Output isn't correct
30 Incorrect 5 ms 3044 KB Output isn't correct
31 Correct 5 ms 3072 KB Output is correct
32 Incorrect 5 ms 3072 KB Output isn't correct
33 Correct 5 ms 3072 KB Output is correct
34 Correct 6 ms 3072 KB Output is correct
35 Incorrect 5 ms 3072 KB Output isn't correct
36 Incorrect 5 ms 3072 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 3324 KB Output isn't correct
2 Incorrect 8 ms 3328 KB Output isn't correct
3 Incorrect 6 ms 3200 KB Output isn't correct
4 Incorrect 7 ms 3328 KB Output isn't correct
5 Incorrect 8 ms 3328 KB Output isn't correct
6 Incorrect 6 ms 3328 KB Output isn't correct
7 Incorrect 6 ms 3328 KB Output isn't correct
8 Incorrect 6 ms 3328 KB Output isn't correct
9 Incorrect 7 ms 3340 KB Output isn't correct
10 Incorrect 7 ms 3328 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 5632 KB Output isn't correct
2 Incorrect 31 ms 5608 KB Output isn't correct
3 Incorrect 35 ms 5632 KB Output isn't correct
4 Incorrect 42 ms 6160 KB Output isn't correct
5 Incorrect 43 ms 6144 KB Output isn't correct
6 Incorrect 33 ms 5632 KB Output isn't correct
7 Incorrect 36 ms 5880 KB Output isn't correct
8 Incorrect 34 ms 5888 KB Output isn't correct
9 Incorrect 35 ms 5760 KB Output isn't correct
10 Incorrect 36 ms 5888 KB Output isn't correct
11 Incorrect 31 ms 6144 KB Output isn't correct
12 Incorrect 41 ms 6144 KB Output isn't correct
13 Incorrect 42 ms 6016 KB Output isn't correct
14 Incorrect 37 ms 6016 KB Output isn't correct
15 Incorrect 52 ms 6016 KB Output isn't correct
16 Incorrect 30 ms 5676 KB Output isn't correct
17 Incorrect 38 ms 5632 KB Output isn't correct
18 Incorrect 36 ms 5632 KB Output isn't correct
19 Incorrect 34 ms 5504 KB Output isn't correct
20 Incorrect 38 ms 5752 KB Output isn't correct