# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
378389 |
2021-03-16T16:47:14 Z |
YJU |
Vim (BOI13_vim) |
C++14 |
|
44 ms |
5060 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=5e2+5;
const ll INF=(1LL<<30);
#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);
}
reverse(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 |
Incorrect |
41 ms |
3948 KB |
Output isn't correct |
2 |
Incorrect |
23 ms |
3180 KB |
Output isn't correct |
3 |
Incorrect |
25 ms |
3052 KB |
Output isn't correct |
4 |
Incorrect |
22 ms |
3180 KB |
Output isn't correct |
5 |
Incorrect |
22 ms |
3180 KB |
Output isn't correct |
6 |
Incorrect |
41 ms |
3692 KB |
Output isn't correct |
7 |
Incorrect |
33 ms |
3820 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
2284 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
2284 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
2284 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
2284 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
2284 KB |
Output isn't correct |
13 |
Incorrect |
44 ms |
3864 KB |
Output isn't correct |
14 |
Incorrect |
23 ms |
3180 KB |
Output isn't correct |
15 |
Incorrect |
20 ms |
3052 KB |
Output isn't correct |
16 |
Incorrect |
23 ms |
3180 KB |
Output isn't correct |
17 |
Incorrect |
22 ms |
3200 KB |
Output isn't correct |
18 |
Incorrect |
20 ms |
3052 KB |
Output isn't correct |
19 |
Incorrect |
19 ms |
3180 KB |
Output isn't correct |
20 |
Incorrect |
20 ms |
3052 KB |
Output isn't correct |
21 |
Incorrect |
21 ms |
3052 KB |
Output isn't correct |
22 |
Incorrect |
22 ms |
3180 KB |
Output isn't correct |
23 |
Incorrect |
17 ms |
3352 KB |
Output isn't correct |
24 |
Incorrect |
14 ms |
2796 KB |
Output isn't correct |
25 |
Incorrect |
16 ms |
3052 KB |
Output isn't correct |
26 |
Incorrect |
21 ms |
3052 KB |
Output isn't correct |
27 |
Incorrect |
27 ms |
3308 KB |
Output isn't correct |
28 |
Incorrect |
34 ms |
3692 KB |
Output isn't correct |
29 |
Incorrect |
32 ms |
3692 KB |
Output isn't correct |
30 |
Incorrect |
20 ms |
3180 KB |
Output isn't correct |
31 |
Incorrect |
15 ms |
2924 KB |
Output isn't correct |
32 |
Incorrect |
19 ms |
3180 KB |
Output isn't correct |
33 |
Incorrect |
22 ms |
3052 KB |
Output isn't correct |
34 |
Incorrect |
24 ms |
3180 KB |
Output isn't correct |
35 |
Incorrect |
27 ms |
3436 KB |
Output isn't correct |
36 |
Incorrect |
31 ms |
3692 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
4588 KB |
Execution killed with signal 11 |
2 |
Runtime error |
5 ms |
4588 KB |
Execution killed with signal 11 |
3 |
Runtime error |
6 ms |
5060 KB |
Execution killed with signal 11 |
4 |
Runtime error |
5 ms |
4588 KB |
Execution killed with signal 11 |
5 |
Runtime error |
5 ms |
4588 KB |
Execution killed with signal 11 |
6 |
Runtime error |
5 ms |
4588 KB |
Execution killed with signal 11 |
7 |
Runtime error |
5 ms |
4588 KB |
Execution killed with signal 11 |
8 |
Runtime error |
6 ms |
4588 KB |
Execution killed with signal 11 |
9 |
Runtime error |
5 ms |
4588 KB |
Execution killed with signal 11 |
10 |
Runtime error |
5 ms |
4588 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
2 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
3 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
4 |
Runtime error |
5 ms |
4844 KB |
Execution killed with signal 11 |
5 |
Runtime error |
5 ms |
4844 KB |
Execution killed with signal 11 |
6 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
7 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
8 |
Runtime error |
5 ms |
4844 KB |
Execution killed with signal 11 |
9 |
Runtime error |
5 ms |
4844 KB |
Execution killed with signal 11 |
10 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
11 |
Runtime error |
6 ms |
4844 KB |
Execution killed with signal 11 |
12 |
Runtime error |
5 ms |
4844 KB |
Execution killed with signal 11 |
13 |
Runtime error |
7 ms |
4844 KB |
Execution killed with signal 11 |
14 |
Runtime error |
5 ms |
4888 KB |
Execution killed with signal 11 |
15 |
Runtime error |
5 ms |
4844 KB |
Execution killed with signal 11 |
16 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
17 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
18 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
19 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |
20 |
Runtime error |
5 ms |
4716 KB |
Execution killed with signal 11 |