이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int ans (int pos, vector <char> mine1, vector <char> mine2) {
if (pos == n) {
return 0;
}
mine1.push_back(s[pos]);
map <char, int> ds;
for (int i = (int)mine1.size() - 1; i >= max(0, (int)mine1.size() - 3); i--) {
ds[mine1[i]]++;
}
int ret = ans(pos + 1, mine1, mine2) + (int)ds.size();
ds.clear();
mine1.pop_back();
mine2.push_back(s[pos]);
for (int i = (int)mine2.size() - 1; i >= max(0, (int)mine2.size() - 3); i--) {
ds[mine2[i]]++;
}
ret = max(ret, ans(pos + 1, mine1, mine2) + (int)ds.size());
return ret;
}
int main () {
cin >> n >> s;
cout << ans(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... |