# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495606 | 2021-12-19T13:04:40 Z | PiejanVDC | Miners (IOI07_miners) | C++17 | 1500 ms | 3892 KB |
#include <bits/stdc++.h> using namespace std; string s; vector<char>v,w; int ans; void dfs(int i) { if(i == s.length()) { int cnt = 0; for(int j = 0 ; j < (int)v.size()-2 ; j++) { //assert(j+2 < v.size()); if(v[j] != v[j+1] && v[j] != v[j+2] && v[j+1] != v[j+2]) { cnt += 3; } else if(v[j] == v[j+1] && v[j] == v[j+2]) cnt++; else cnt += 2; } if(v.size() > 0) cnt++; if(v.size() > 1) cnt += (v[0] != v[1] ? 2 : 1); //cout << w.size() << " "; for(int j = 0 ; j < (int)w.size()-2 ; j++) { //assert(j+2 < w.size()); if(w[j] != w[j+1] && w[j] != w[j+2] && w[j+1] != w[j+2]) { cnt += 3; } else if(w[j] == w[j+1] && w[j] == w[j+2]) cnt++; else cnt += 2; } if(w.size() > 0) cnt++; if(w.size() > 1) cnt += (w[0] != w[1] ? 2 : 1); ans = max(ans,cnt); return; } v.push_back(s[i]); dfs(i+1); v.pop_back(); w.push_back(s[i]); dfs(i+1); w.pop_back(); } signed main() { int n; cin>>n; cin>>s; dfs(0); cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 328 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1553 ms | 208 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1578 ms | 208 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1579 ms | 464 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1575 ms | 592 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1586 ms | 1120 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1559 ms | 2996 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1588 ms | 3892 KB | Time limit exceeded |