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>
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 2e5+1;
int n;
string s;
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n >> s;
if (n <= 20) {
int sol = 0;
for (int msk = 0; msk < (1 << n); msk++) {
int coal = 0;
vector<int> fr, sc;
for (int i = 0; i < n; i++) {
if (msk>>i&1) swap(fr, sc);
fr.push_back(s[i]);
if (fr.size() == 1) coal += 1;
else if (fr.size() == 2) coal += 1+(fr[1] != fr[0]);
else {
set<int> cc;
cc.insert(fr[fr.size()-1]);
cc.insert(fr[fr.size()-2]);
cc.insert(fr[fr.size()-3]);
coal += cc.size();
}
if (msk>>i&1) swap(fr, sc);
}
sol = max(sol, coal);
}
cout << sol;
return 0;
}
}
# | 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... |