# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495606 | PiejanVDC | Miners (IOI07_miners) | C++17 | 1588 ms | 3892 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |