이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using std::vector;
using std::array;
using std::pair;
using std::tuple;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
std::cin >> N;
vector<int> A(N);
for (auto& x : A) {
char c;
std::cin >> c;
x = c - 'a';
}
int ans_x = N + 1, ans_y = 1;
int ans_l = -1, ans_r = -1;
for (int d = 1; d <= 26; ++d) {
int j = 0, k = 0;
array<int, 26> count = {};
for (int i = 0; i < N; ++i) {
while (j < N) {
if (count[A[j]] == 0) {
k += 1;
}
if (k > d) {
k -= 1;
break;
}
count[A[j]] += 1;
j += 1;
}
if (ans_x * (j - i) > d * ans_y) {
ans_x = d, ans_y = j - i;
ans_l = i, ans_r = j;
}
count[A[i]] -= 1;
if (count[A[i]] == 0) {
k -= 1;
}
}
}
std::cout << ans_l + 1 << ' ' << ans_r << '\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... |