Submission #844371

#TimeUsernameProblemLanguageResultExecution timeMemory
844371vjudge1Nivelle (COCI20_nivelle)C++17
24 / 110
1091 ms24668 KiB
#include <bits/stdc++.h> #define endl "\n" #define pb push_back #define int long long using namespace std; const int inf = 2e18 + 5; const int N = 2e5 + 5; const int mod = 1e9 + 7; int32_t main(){ //freopen("in.txt","r", stdin); int n; cin>>n; string s; cin>>s; int mx = 0; vector<vector<int> > pre(n+1, vector<int>(26)); for(int i = 0; i < n; i++){ mx = max(mx, (int)(s[i] - 'a')); for(int j = 0; j < 26; j++){ pre[i+1][j] = pre[i][j] + (s[i] == (char)('a' + j)); } } pair<int, int> best = {1, 1}; int l = 1, r = 1; for(int i = 0; i < n; i++){ for(int j = i+1; j <= n; j++){ int df = 0, len = j - i; for(int k = 0; k < 26; k++){ if(pre[j][k] - pre[i][k] > 0) df++; } pair<int, int> option = {len, df}; if(best.first * option.second < option.first * best.second){ best = {len, df}; r = j, l = i+1; } } } cout<<l<<" "<<r<<endl; return 0; }
#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...