# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211793 | socho | Miners (IOI07_miners) | C++14 | 1591 ms | 1100 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;
// #define endl '\n'
// #define int long long
int diff(int a, int b, int c) {
if (a == b && b == c) return 1;
if (a == b || b == c || a == c) return 2;
return 3;
}
signed main() {
int n;
cin >> n;
string s;
cin >> s;
int best = 0;
for (int i=0; i<(1<<n); i++) {
deque<int> le, ri;
int here = 0;
for (int j=0; j<n; j++) {
if ((1 << j) & i) le.push_back(s[j]);
else ri.push_back(s[j]);
}
for (int i=0; i<le.size(); i++) {
if (i == 0) here++;
else if (i == 1) {
if (le[0] == le[1]) here++;
else here += 2;
}
else {
here += diff(le[i-2], le[i-1], le[i]);
}
}
for (int i=0; i<ri.size(); i++) {
if (i == 0) here++;
else if (i == 1) {
if (ri[0] == ri[1]) here++;
else here += 2;
}
else {
here += diff(ri[i-2], ri[i-1], ri[i]);
}
}
best = max(best, here);
}
cout << best << endl;
}
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... |