이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
const int maxn = 1e6 + 5, abc = 26;
int ans = 0;
int pf[abc][abc], pfmin[abc][abc], last[abc][abc];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
string s;
cin >> s;
for (int i = 0; i < abc; i++) for (int j = 0; j < abc; j++) pf[i][j] = -1e9;
for (int i = 0; i < n; i++)
{
int a = s[i] - 'a';
for (int b = 0; b < abc; b++) if (a ^ b)
{
pf[a][b]++;
ans = max(ans, pf[a][b] - pfmin[a][b]);
pfmin[b][a] = min(pfmin[b][a], last[b][a]);
last[b][a] = --pf[b][a];
ans = max(ans, pf[b][a] - pfmin[b][a]);
}
}
cout << ans << "\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... |