# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
378425 |
2021-03-16T18:07:24 Z |
YJU |
Vim (BOI13_vim) |
C++14 |
|
2000 ms |
232652 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=7e4+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][11],e[N];
unordered_map<ll,ll> dp[N];
string s;
vector<ll> loc;
ll n,m;
ll f(ll have,ll id){
if(have==m)return 0;
if(dp[have].find(id)!=dp[have].end())return dp[have][id];
dp[have][id]=INF;
if(id>loc[have]){
ll nhave=lwb(loc.begin(),loc.end(),id)-loc.begin();
dp[have][id]=min(dp[have][id],f(nhave,e[loc[have]])+(id-loc[have]));
}
REP(j,10){
if(j=='e'-'a'||nxt[id+1][j]==n)continue;
dp[have][id]=min(dp[have][id],f(have,nxt[id+1][j])+2);
}
return dp[have][id];
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>s;
REP(j,10)nxt[n][j]=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;
e[i]=(s[i+1]=='e'?e[i+1]:i+1);
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
5868 KB |
Output is correct |
2 |
Correct |
21 ms |
6252 KB |
Output is correct |
3 |
Correct |
13 ms |
5484 KB |
Output is correct |
4 |
Correct |
23 ms |
6124 KB |
Output is correct |
5 |
Correct |
26 ms |
6124 KB |
Output is correct |
6 |
Correct |
41 ms |
6892 KB |
Output is correct |
7 |
Correct |
32 ms |
6764 KB |
Output is correct |
8 |
Correct |
3 ms |
4204 KB |
Output is correct |
9 |
Correct |
3 ms |
4204 KB |
Output is correct |
10 |
Correct |
3 ms |
4204 KB |
Output is correct |
11 |
Correct |
3 ms |
4204 KB |
Output is correct |
12 |
Correct |
3 ms |
4204 KB |
Output is correct |
13 |
Correct |
21 ms |
5868 KB |
Output is correct |
14 |
Correct |
20 ms |
6252 KB |
Output is correct |
15 |
Correct |
13 ms |
5484 KB |
Output is correct |
16 |
Correct |
19 ms |
6252 KB |
Output is correct |
17 |
Correct |
30 ms |
6380 KB |
Output is correct |
18 |
Correct |
20 ms |
5996 KB |
Output is correct |
19 |
Correct |
16 ms |
5484 KB |
Output is correct |
20 |
Correct |
20 ms |
5868 KB |
Output is correct |
21 |
Correct |
23 ms |
6124 KB |
Output is correct |
22 |
Correct |
26 ms |
6144 KB |
Output is correct |
23 |
Correct |
18 ms |
5868 KB |
Output is correct |
24 |
Correct |
18 ms |
5612 KB |
Output is correct |
25 |
Correct |
19 ms |
5740 KB |
Output is correct |
26 |
Correct |
23 ms |
5996 KB |
Output is correct |
27 |
Correct |
30 ms |
6508 KB |
Output is correct |
28 |
Correct |
35 ms |
6892 KB |
Output is correct |
29 |
Correct |
32 ms |
6764 KB |
Output is correct |
30 |
Correct |
22 ms |
6124 KB |
Output is correct |
31 |
Correct |
20 ms |
5612 KB |
Output is correct |
32 |
Correct |
23 ms |
5996 KB |
Output is correct |
33 |
Correct |
32 ms |
6124 KB |
Output is correct |
34 |
Correct |
29 ms |
6252 KB |
Output is correct |
35 |
Correct |
28 ms |
6508 KB |
Output is correct |
36 |
Correct |
32 ms |
6764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2081 ms |
136172 KB |
Time limit exceeded |
2 |
Execution timed out |
2083 ms |
166072 KB |
Time limit exceeded |
3 |
Correct |
718 ms |
53372 KB |
Output is correct |
4 |
Correct |
1982 ms |
136100 KB |
Output is correct |
5 |
Execution timed out |
2093 ms |
159284 KB |
Time limit exceeded |
6 |
Execution timed out |
2095 ms |
154716 KB |
Time limit exceeded |
7 |
Execution timed out |
2047 ms |
145052 KB |
Time limit exceeded |
8 |
Execution timed out |
2096 ms |
153384 KB |
Time limit exceeded |
9 |
Execution timed out |
2095 ms |
158788 KB |
Time limit exceeded |
10 |
Execution timed out |
2092 ms |
163524 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2089 ms |
183956 KB |
Time limit exceeded |
2 |
Execution timed out |
2087 ms |
167976 KB |
Time limit exceeded |
3 |
Execution timed out |
2099 ms |
170780 KB |
Time limit exceeded |
4 |
Execution timed out |
2099 ms |
197840 KB |
Time limit exceeded |
5 |
Execution timed out |
2058 ms |
188076 KB |
Time limit exceeded |
6 |
Execution timed out |
2089 ms |
151908 KB |
Time limit exceeded |
7 |
Execution timed out |
2085 ms |
167784 KB |
Time limit exceeded |
8 |
Execution timed out |
2056 ms |
165480 KB |
Time limit exceeded |
9 |
Execution timed out |
2062 ms |
159464 KB |
Time limit exceeded |
10 |
Execution timed out |
2104 ms |
159860 KB |
Time limit exceeded |
11 |
Execution timed out |
2092 ms |
188320 KB |
Time limit exceeded |
12 |
Execution timed out |
2101 ms |
190236 KB |
Time limit exceeded |
13 |
Execution timed out |
2106 ms |
176044 KB |
Time limit exceeded |
14 |
Execution timed out |
2095 ms |
182572 KB |
Time limit exceeded |
15 |
Execution timed out |
2099 ms |
170888 KB |
Time limit exceeded |
16 |
Execution timed out |
2097 ms |
232652 KB |
Time limit exceeded |
17 |
Execution timed out |
2095 ms |
194668 KB |
Time limit exceeded |
18 |
Execution timed out |
2079 ms |
174952 KB |
Time limit exceeded |
19 |
Execution timed out |
2045 ms |
178736 KB |
Time limit exceeded |
20 |
Execution timed out |
2099 ms |
165408 KB |
Time limit exceeded |