이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
for (int i=1;i<=n;i++){
while (j<=n&&!ok){
if (j==n) break;
j++;
if (ac[s[j]-'a']==0) ct++;
ac[s[j]-'a']++;
if (l==0) {
best=ct/(double)(j-i+1);
l=i,r=j;
}
//cout<<i<<" "<<j<<" "<<ct/(double)(j-i+1)<<" "<<best<<"\n";
if (best>ct/(double)(j-i+1)){
best=ct/(double)(j-i+1);
l=i,r=j;
}
if (best<ct/(double)(j-i+1)) {
ok=1;
break;
}
}
if (best>ct/(double)(j-i+1)){
best=ct/(double)(j-i+1);
l=i,r=j;
}
if (best<ct/(double)(j-i+1)|| i==j) ok=0;
ac[s[i]-'a']--;
if (ac[s[i]-'a']==0)--ct;
}
cout<<l<<" "<<r<<"\n";
}
# | 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... |