이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |