# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
888092 | votranngocvy | Nivelle (COCI20_nivelle) | C++14 | 24 ms | 860 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int inf = 0x3f3f3f3f;
int a[N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
char x;
cin >> x;
a[i] = x - 'a';
}
int ans = inf,L,R;
for (int i = 1; i <= 26; i++) {
vector<int>cnt(30,0);
int r = 1,tmp = 0;
for (int l = 1; l <= n; l++) {
if (l > 1) {
cnt[a[l - 1]]--;
if (cnt[a[l - 1]] == 0) tmp--;
}
while (r <= n && tmp < i) {
cnt[a[r]]++;
if (cnt[a[r]] == 1) tmp++;
r++;
}
if (tmp == i && (r - l + 1) / i < ans) {
ans = (r - l + 1) / i;
L = l,R = r;
}
}
}
cout << L << " " << R << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |