제출 #844478

#제출 시각아이디문제언어결과실행 시간메모리
844478vjudge1Nivelle (COCI20_nivelle)C++17
24 / 110
1055 ms11092 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 2e5 + 5, MOD = 1e9 + 7; int arr[N][26]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; string str; cin >> n >> str; str = "#" + str; for(int i = 1; i <= n; i++) { arr[i][str[i] - 'a']++; } for(int i = 1; i <= n; i++) { for(int j = 0; j < 26; j++) { arr[i][j] += arr[i - 1][j]; } } int left = 1, right = 1; long double ans = 1; for(int i = 1; i <= n; i++) { for(int j = i + 1; j <= n; j++) { int cnt = 0; for(int k = 0; k < 26; k++) { if(arr[j][k] - arr[i - 1][k]) { cnt++; } } long double l = j - i + 1; if((long double)cnt / l < ans) { ans = (long double)cnt / l; left = i, right = j; } } } cout << left << " " << right << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...