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;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
//freopen ("input", "r", stdin);
int n;
string s;
cin >> n >> s;
function<int(deque<int>)> eval = [&] (deque<int> d) {
set<int> F;
for (auto &x : d) {
F.insert(x);
}
return (int) F.size();
};
int sol = 0;
deque<int> a, b;
for (int i = 1; i <= n; i++) {
if ((int) a.size() == 3) a.pop_front();
if ((int) b.size() == 3) b.pop_front();
char ch = s[i - 1];
a.push_back(ch);
b.push_back(ch);
int X = eval(a);
int Y = eval(b);
if (X > Y) {
b.pop_back();
sol += X;
} else {
sol += Y;
a.pop_back();
}
}
cout << sol << "\n";
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... |