# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
256382 | 2020-08-02T15:51:15 Z | shayan_p | Vim (BOI13_vim) | C++14 | 372 ms | 524292 KB |
// And you curse yourself for things you never done #include<bits/stdc++.h> #define F first #define S second #define PB push_back #define sz(s) int((s).size()) #define bit(n,k) (((n)>>(k))&1) using namespace std; typedef long long ll; typedef pair<int,int> pii; const int maxn = 70010, mod = 1e9 + 7, inf = 1e9 + 10; int nxt[maxn][10], lst[10]; unordered_map<int, int> dp[maxn]; vector<int> poses; int solve(int i, int j){ if(i >= sz(poses)) return 0; if(dp[i].count(j)) return dp[i][j]; int ans = inf; if(j >= poses[i]) ans = j - poses[i] + solve( upper_bound(poses.begin(), poses.end(), j) - poses.begin(), poses[i] ); if(nxt[ poses[i] ][8] + 10 < j) return dp[i][j] = ans; int pt = lower_bound(nxt[j], nxt[j] + 10, poses[i]) - nxt[j]; for(int w = 8 ; w >= 0 && nxt[j][w] != j && w >= pt-1; w--) ans = min(ans, 2 + solve(i, nxt[j][w])); return dp[i][j] = ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(); for(int i = 0; i < maxn; i++){ dp[i].reserve(1024); dp[i].max_load_factor(0.25); } int n; cin >> n; string _s, s; cin >> _s; int ans = 0; for(int i = 0; i < n; i++){ if(_s[i] == 'e') ans+= 2; if(_s[i] == 'e' && _s[i + 1] != 'e') poses.PB(sz(s)); if(_s[i] != 'e') s+= _s[i]; } memset(lst, -1, sizeof lst); memset(nxt, -1, sizeof nxt); n = sz(s); for(int i = n-1; i >= 0; i--){ for(int j = 0; j < 9; j++) nxt[i][j] = (lst[j] == -1 ? i : lst[j]); sort(nxt[i], nxt[i] + 9); nxt[i][9] = inf; int id = (s[i] - 'a') - (s[i] > 'e'); lst[id] = i; } ans+= solve(0, 0); return cout << ans << "\n", 0; }
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 266 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Runtime error | 255 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
3 | Runtime error | 262 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
4 | Runtime error | 247 ms | 524288 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
5 | Runtime error | 264 ms | 524288 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
6 | Runtime error | 262 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
7 | Runtime error | 253 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
8 | Runtime error | 293 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
9 | Runtime error | 251 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
10 | Runtime error | 262 ms | 524288 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
11 | Runtime error | 304 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
12 | Runtime error | 274 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
13 | Runtime error | 254 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
14 | Runtime error | 272 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
15 | Runtime error | 270 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
16 | Runtime error | 270 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
17 | Runtime error | 268 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
18 | Runtime error | 300 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
19 | Runtime error | 273 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
20 | Runtime error | 279 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
21 | Runtime error | 303 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
22 | Runtime error | 281 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
23 | Runtime error | 272 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
24 | Runtime error | 372 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
25 | Runtime error | 313 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
26 | Runtime error | 345 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
27 | Runtime error | 293 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
28 | Runtime error | 288 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
29 | Runtime error | 284 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
30 | Runtime error | 263 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
31 | Runtime error | 293 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
32 | Runtime error | 267 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
33 | Runtime error | 265 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
34 | Runtime error | 277 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
35 | Runtime error | 262 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
36 | Runtime error | 263 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 287 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Runtime error | 268 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
3 | Runtime error | 264 ms | 524288 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
4 | Runtime error | 287 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
5 | Runtime error | 267 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
6 | Runtime error | 285 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
7 | Runtime error | 272 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
8 | Runtime error | 282 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
9 | Runtime error | 269 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
10 | Runtime error | 272 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 306 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Runtime error | 274 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
3 | Runtime error | 266 ms | 524288 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
4 | Runtime error | 273 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
5 | Runtime error | 263 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
6 | Runtime error | 285 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
7 | Runtime error | 271 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
8 | Runtime error | 277 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
9 | Runtime error | 262 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
10 | Runtime error | 272 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
11 | Runtime error | 263 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
12 | Runtime error | 264 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
13 | Runtime error | 286 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
14 | Runtime error | 254 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
15 | Runtime error | 269 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
16 | Runtime error | 260 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
17 | Runtime error | 281 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
18 | Runtime error | 273 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
19 | Runtime error | 272 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
20 | Runtime error | 276 ms | 524292 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |