# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
378424 |
2021-03-16T18:06:40 Z |
YJU |
Vim (BOI13_vim) |
C++14 |
|
2000 ms |
114524 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];
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 |
44 ms |
5868 KB |
Output is correct |
2 |
Correct |
43 ms |
6636 KB |
Output is correct |
3 |
Correct |
24 ms |
5356 KB |
Output is correct |
4 |
Correct |
59 ms |
6316 KB |
Output is correct |
5 |
Correct |
63 ms |
6380 KB |
Output is correct |
6 |
Correct |
83 ms |
7532 KB |
Output is correct |
7 |
Correct |
76 ms |
7532 KB |
Output is correct |
8 |
Correct |
3 ms |
3692 KB |
Output is correct |
9 |
Correct |
3 ms |
3692 KB |
Output is correct |
10 |
Correct |
3 ms |
3692 KB |
Output is correct |
11 |
Correct |
3 ms |
3692 KB |
Output is correct |
12 |
Correct |
3 ms |
3692 KB |
Output is correct |
13 |
Correct |
47 ms |
5868 KB |
Output is correct |
14 |
Correct |
44 ms |
6636 KB |
Output is correct |
15 |
Correct |
24 ms |
5356 KB |
Output is correct |
16 |
Correct |
43 ms |
6528 KB |
Output is correct |
17 |
Correct |
82 ms |
6892 KB |
Output is correct |
18 |
Correct |
54 ms |
6124 KB |
Output is correct |
19 |
Correct |
32 ms |
5612 KB |
Output is correct |
20 |
Correct |
42 ms |
5996 KB |
Output is correct |
21 |
Correct |
52 ms |
6252 KB |
Output is correct |
22 |
Correct |
59 ms |
6380 KB |
Output is correct |
23 |
Correct |
41 ms |
6124 KB |
Output is correct |
24 |
Correct |
48 ms |
5612 KB |
Output is correct |
25 |
Correct |
48 ms |
5996 KB |
Output is correct |
26 |
Correct |
56 ms |
6288 KB |
Output is correct |
27 |
Correct |
83 ms |
7020 KB |
Output is correct |
28 |
Correct |
105 ms |
7532 KB |
Output is correct |
29 |
Correct |
77 ms |
7532 KB |
Output is correct |
30 |
Correct |
52 ms |
6508 KB |
Output is correct |
31 |
Correct |
49 ms |
5868 KB |
Output is correct |
32 |
Correct |
66 ms |
6380 KB |
Output is correct |
33 |
Correct |
59 ms |
6636 KB |
Output is correct |
34 |
Correct |
65 ms |
6636 KB |
Output is correct |
35 |
Correct |
66 ms |
6764 KB |
Output is correct |
36 |
Correct |
75 ms |
7532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2083 ms |
78984 KB |
Time limit exceeded |
2 |
Execution timed out |
2099 ms |
75464 KB |
Time limit exceeded |
3 |
Execution timed out |
2076 ms |
76596 KB |
Time limit exceeded |
4 |
Execution timed out |
2104 ms |
80104 KB |
Time limit exceeded |
5 |
Execution timed out |
2054 ms |
77560 KB |
Time limit exceeded |
6 |
Execution timed out |
2098 ms |
77512 KB |
Time limit exceeded |
7 |
Execution timed out |
2084 ms |
85952 KB |
Time limit exceeded |
8 |
Execution timed out |
2037 ms |
77724 KB |
Time limit exceeded |
9 |
Execution timed out |
2085 ms |
76888 KB |
Time limit exceeded |
10 |
Execution timed out |
2081 ms |
87968 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2082 ms |
82444 KB |
Time limit exceeded |
2 |
Execution timed out |
2080 ms |
98160 KB |
Time limit exceeded |
3 |
Execution timed out |
2025 ms |
93316 KB |
Time limit exceeded |
4 |
Execution timed out |
2076 ms |
114524 KB |
Time limit exceeded |
5 |
Execution timed out |
2097 ms |
86568 KB |
Time limit exceeded |
6 |
Execution timed out |
2088 ms |
83088 KB |
Time limit exceeded |
7 |
Execution timed out |
2093 ms |
85152 KB |
Time limit exceeded |
8 |
Execution timed out |
2080 ms |
80212 KB |
Time limit exceeded |
9 |
Execution timed out |
2092 ms |
92208 KB |
Time limit exceeded |
10 |
Execution timed out |
2082 ms |
81100 KB |
Time limit exceeded |
11 |
Execution timed out |
2053 ms |
110480 KB |
Time limit exceeded |
12 |
Execution timed out |
2081 ms |
83944 KB |
Time limit exceeded |
13 |
Execution timed out |
2071 ms |
97368 KB |
Time limit exceeded |
14 |
Execution timed out |
2047 ms |
98600 KB |
Time limit exceeded |
15 |
Execution timed out |
2044 ms |
85312 KB |
Time limit exceeded |
16 |
Execution timed out |
2099 ms |
109036 KB |
Time limit exceeded |
17 |
Execution timed out |
2088 ms |
77208 KB |
Time limit exceeded |
18 |
Execution timed out |
2069 ms |
91628 KB |
Time limit exceeded |
19 |
Execution timed out |
2087 ms |
95568 KB |
Time limit exceeded |
20 |
Execution timed out |
2084 ms |
73692 KB |
Time limit exceeded |