# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
378391 |
2021-03-16T16:50:08 Z |
YJU |
Vim (BOI13_vim) |
C++14 |
|
417 ms |
398316 KB |
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector,Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll N=5e3+5;
const ll INF=(1LL<<60);
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define lwb lower_bound
ll nxt[N][12],suffix_sum[N],dp[N][N];
string s;
vector<ll> loc;
ll n,m;
ll f(ll have,ll id){
if(have==m)return 0;
if(dp[have][id]!=-1)return dp[have][id];
//cout<<have<<" "<<id<<"\n";
dp[have][id]=INF;
REP(j,10){
if(j=='e'-'a'||nxt[id+1][j]==n)continue;
ll to=nxt[id+1][j];
if(to>loc[have]){
ll nhave=lwb(loc.begin(),loc.end(),to)-loc.begin();
dp[have][id]=min(dp[have][id],2+(to-loc[have])+f(nhave,loc[have]+1));
}else{
dp[have][id]=min(dp[have][id],f(have,to)+2);
}
}
return dp[have][id];
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
memset(dp,-1,sizeof(dp));
cin>>n>>s;
REP(j,10)nxt[n][10]=n;
for(int i=n-1;i>=0;i--){
REP(j,10)nxt[i][j]=nxt[i+1][j];
nxt[i][s[i]-'a']=i;
if(s[i]=='e')loc.pb(i);
}
sort(loc.begin(),loc.end());
m=loc.size();
cout<<f(0,0)+m<<"\n";
//REP(i,m)REP(j,n)cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
196460 KB |
Output is correct |
2 |
Incorrect |
110 ms |
196460 KB |
Output isn't correct |
3 |
Incorrect |
105 ms |
196460 KB |
Output isn't correct |
4 |
Correct |
106 ms |
196588 KB |
Output is correct |
5 |
Correct |
105 ms |
196460 KB |
Output is correct |
6 |
Correct |
105 ms |
196460 KB |
Output is correct |
7 |
Incorrect |
106 ms |
196716 KB |
Output isn't correct |
8 |
Correct |
105 ms |
196460 KB |
Output is correct |
9 |
Correct |
104 ms |
196588 KB |
Output is correct |
10 |
Correct |
106 ms |
196460 KB |
Output is correct |
11 |
Correct |
105 ms |
196460 KB |
Output is correct |
12 |
Correct |
104 ms |
196460 KB |
Output is correct |
13 |
Correct |
108 ms |
196460 KB |
Output is correct |
14 |
Incorrect |
108 ms |
196460 KB |
Output isn't correct |
15 |
Incorrect |
108 ms |
196588 KB |
Output isn't correct |
16 |
Incorrect |
109 ms |
196460 KB |
Output isn't correct |
17 |
Correct |
111 ms |
196588 KB |
Output is correct |
18 |
Correct |
108 ms |
196460 KB |
Output is correct |
19 |
Incorrect |
109 ms |
196716 KB |
Output isn't correct |
20 |
Correct |
106 ms |
196460 KB |
Output is correct |
21 |
Correct |
107 ms |
196460 KB |
Output is correct |
22 |
Correct |
105 ms |
196460 KB |
Output is correct |
23 |
Correct |
106 ms |
196844 KB |
Output is correct |
24 |
Correct |
107 ms |
196460 KB |
Output is correct |
25 |
Correct |
105 ms |
196588 KB |
Output is correct |
26 |
Correct |
105 ms |
196500 KB |
Output is correct |
27 |
Correct |
105 ms |
196460 KB |
Output is correct |
28 |
Correct |
113 ms |
196460 KB |
Output is correct |
29 |
Incorrect |
106 ms |
196588 KB |
Output isn't correct |
30 |
Incorrect |
105 ms |
196588 KB |
Output isn't correct |
31 |
Correct |
105 ms |
196460 KB |
Output is correct |
32 |
Incorrect |
110 ms |
196716 KB |
Output isn't correct |
33 |
Correct |
105 ms |
196460 KB |
Output is correct |
34 |
Correct |
105 ms |
196460 KB |
Output is correct |
35 |
Correct |
106 ms |
196520 KB |
Output is correct |
36 |
Incorrect |
105 ms |
196716 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
197240 KB |
Output isn't correct |
2 |
Correct |
113 ms |
197044 KB |
Output is correct |
3 |
Incorrect |
110 ms |
196716 KB |
Output isn't correct |
4 |
Incorrect |
112 ms |
197228 KB |
Output isn't correct |
5 |
Incorrect |
115 ms |
197120 KB |
Output isn't correct |
6 |
Incorrect |
110 ms |
196972 KB |
Output isn't correct |
7 |
Incorrect |
188 ms |
197228 KB |
Output isn't correct |
8 |
Incorrect |
116 ms |
196972 KB |
Output isn't correct |
9 |
Correct |
115 ms |
197228 KB |
Output is correct |
10 |
Incorrect |
264 ms |
213612 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
370 ms |
398188 KB |
Execution killed with signal 11 |
2 |
Runtime error |
376 ms |
398060 KB |
Execution killed with signal 11 |
3 |
Runtime error |
372 ms |
397932 KB |
Execution killed with signal 11 |
4 |
Runtime error |
372 ms |
398316 KB |
Execution killed with signal 11 |
5 |
Runtime error |
407 ms |
398188 KB |
Execution killed with signal 11 |
6 |
Runtime error |
375 ms |
398036 KB |
Execution killed with signal 11 |
7 |
Runtime error |
368 ms |
398188 KB |
Execution killed with signal 11 |
8 |
Runtime error |
370 ms |
398060 KB |
Execution killed with signal 11 |
9 |
Runtime error |
378 ms |
398316 KB |
Execution killed with signal 11 |
10 |
Runtime error |
368 ms |
397932 KB |
Execution killed with signal 11 |
11 |
Runtime error |
417 ms |
398060 KB |
Execution killed with signal 11 |
12 |
Runtime error |
377 ms |
398316 KB |
Execution killed with signal 11 |
13 |
Runtime error |
384 ms |
398188 KB |
Execution killed with signal 11 |
14 |
Runtime error |
367 ms |
398316 KB |
Execution killed with signal 11 |
15 |
Runtime error |
380 ms |
398060 KB |
Execution killed with signal 11 |
16 |
Runtime error |
383 ms |
398060 KB |
Execution killed with signal 11 |
17 |
Runtime error |
367 ms |
398060 KB |
Execution killed with signal 11 |
18 |
Runtime error |
370 ms |
398060 KB |
Execution killed with signal 11 |
19 |
Runtime error |
385 ms |
397988 KB |
Execution killed with signal 11 |
20 |
Runtime error |
388 ms |
398060 KB |
Execution killed with signal 11 |