# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
44240 |
2018-03-30T19:01:12 Z |
snat123 |
Vim (BOI13_vim) |
C++14 |
|
2000 ms |
4044 KB |
#include<bits/stdc++.h>
using namespace std;
vector<int> ind[10];
string s;
int dp[501][501];
int calc(int index, int k){
if(k>0 && dp[index][k]!=0) return dp[index][k];
int indexx=index, kk=k;
if(k==ind[4].size()-1) return 0;
int res=INT_MAX, next_e=ind[4][k+1];
while(index>=next_e){
//cout << next_e << " " << index << " " << dp[indexx][kk]<<endl;
if(s[index]!='e'){
index--;
dp[indexx][kk]++;
}
else{
if(index!=next_e){
index--;
k++;
dp[indexx][kk]+=2;
}
else{
while(s[index]=='e'){
index++;
}
dp[indexx][kk]++;
k++;
break;
}
}
}
//cout << "index->" << index << " next_e->" << next_e << " k->" << k << " dp->" << dp[indexx][kk] << endl;
if(k==ind[4].size()-1) return (dp[indexx][kk]);
for(int i=0; i<10; i++){
if(i==('e'-'a') || ind[i].size()==0) continue;
int next=upper_bound(ind[i].begin(), ind[i].end(), index)-ind[i].begin();
if(next==ind[i].size()) continue;
next=ind[i][next];
//cout << i << " " << index << " " << next << " " << k << " " << res << endl;
if(kk>=0)res=min(res, calc(next, k)+2);
else res=min(res, calc(next, k)+2);
//cout << "i->" << i << " index->" << index << " next->" << next << " k->" << k << " res->" << res << endl;
}
//cout << indexx << " " << kk << " " << cntt << " " << res << endl;
//return res;
if(res!=INT_MAX) dp[indexx][kk]+=res;
return (dp[indexx][kk]);
}
int main(){
memset(dp, 0, sizeof dp);
int n;
cin >> n >> s;
for(int i=0; i<n; i++){
ind[s[i]-'a'].push_back(i);
}
int k=0;
cout << calc(0, -1);
return 0;
}
Compilation message
vim.cpp: In function 'int calc(int, int)':
vim.cpp:12:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(k==ind[4].size()-1) return 0;
~^~~~~~~~~~~~~~~~~
vim.cpp:37:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(k==ind[4].size()-1) return (dp[indexx][kk]);
~^~~~~~~~~~~~~~~~~
vim.cpp:41:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(next==ind[i].size()) continue;
~~~~^~~~~~~~~~~~~~~
vim.cpp: In function 'int main()':
vim.cpp:61:6: warning: unused variable 'k' [-Wunused-variable]
int k=0;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1272 KB |
Output is correct |
2 |
Incorrect |
3 ms |
1384 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
1576 KB |
Output isn't correct |
4 |
Correct |
3 ms |
1576 KB |
Output is correct |
5 |
Correct |
3 ms |
1576 KB |
Output is correct |
6 |
Correct |
3 ms |
1576 KB |
Output is correct |
7 |
Correct |
3 ms |
1576 KB |
Output is correct |
8 |
Correct |
3 ms |
1576 KB |
Output is correct |
9 |
Correct |
3 ms |
1576 KB |
Output is correct |
10 |
Correct |
2 ms |
1576 KB |
Output is correct |
11 |
Correct |
2 ms |
1576 KB |
Output is correct |
12 |
Correct |
2 ms |
1576 KB |
Output is correct |
13 |
Correct |
3 ms |
1620 KB |
Output is correct |
14 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
15 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
16 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
17 |
Correct |
3 ms |
1620 KB |
Output is correct |
18 |
Correct |
3 ms |
1620 KB |
Output is correct |
19 |
Incorrect |
4 ms |
1620 KB |
Output isn't correct |
20 |
Correct |
4 ms |
1620 KB |
Output is correct |
21 |
Correct |
4 ms |
1620 KB |
Output is correct |
22 |
Correct |
3 ms |
1620 KB |
Output is correct |
23 |
Incorrect |
4 ms |
1620 KB |
Output isn't correct |
24 |
Execution timed out |
2067 ms |
1620 KB |
Time limit exceeded |
25 |
Correct |
3 ms |
1620 KB |
Output is correct |
26 |
Correct |
3 ms |
1620 KB |
Output is correct |
27 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
28 |
Correct |
3 ms |
1620 KB |
Output is correct |
29 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
30 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
31 |
Execution timed out |
2070 ms |
1620 KB |
Time limit exceeded |
32 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
33 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
34 |
Correct |
3 ms |
1620 KB |
Output is correct |
35 |
Correct |
3 ms |
1620 KB |
Output is correct |
36 |
Correct |
3 ms |
1620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
4 ms |
2788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
3636 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
7 ms |
3708 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
7 ms |
3744 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
8 ms |
3744 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
7 ms |
3744 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
7 ms |
3752 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
7 ms |
3772 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
9 ms |
3820 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
7 ms |
3820 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
7 ms |
3820 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
7 ms |
3820 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
7 ms |
3820 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
8 ms |
4044 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
8 ms |
4044 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
8 ms |
4044 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
7 ms |
4044 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
7 ms |
4044 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
7 ms |
4044 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
7 ms |
4044 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
7 ms |
4044 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |