Submission #476354

#TimeUsernameProblemLanguageResultExecution timeMemory
476354starplatNivelle (COCI20_nivelle)C++14
0 / 110
5 ms460 KiB
#include <bits/stdc++.h> using namespace std; string s; int l,r,n,j,ct,ac[150],ok; double best; int main() { cin>>n>>s; s='#'+s; ok=1; for (int i=1;i<=n;i++){ while (j<n&&ok){ j++; //cout<<i<<" "<<j<<"\n"; if (ac[s[j]-'a']==0) ct++; ac[s[j]-'a']++; if (l==0){ best=ct/(double)(j-i+1); l=i,r=j; } else if (best>ct/(double)(j-i+1)){ best=ct/(double)(j-i+1); l=i,r=j; } else if (best<ct/(double)(j-i+1)) { ac[s[j]-'a']--; if (ac[s[j]-'a']==0) --ct; --j; break; } } while (best>=ct/(double)(j-i+1)&&i<=n&&i<j) { best=ct/(double)(j-i+1); l=i,r=j; ac[s[i]-'a']--; if (ac[s[i]-'a']==0) ct--; i++; } } cout<<l<<" "<<r<<"\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...