# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442895 | nadidadit | Nivelle (COCI20_nivelle) | C++17 | 1088 ms | 20940 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std;
int main()
{
ll n;
cin>>n;
string a;
cin>>a;
ll l,r;
ld mi=129198.0000000;
ll cnt[n+1][26];
for(ll i=0;i<26;i++)
{
cnt[0][i]=0;
}
for(int i=1;i<=n;i++)
{
char x=a[i-1];
ll y=x-'a';
cnt[i][y]=cnt[i-1][y]+1;
for(int j=0;j<26;j++)
{
if(j!=y)
{
cnt[i][j]=cnt[i-1][j];
}
}
}
for(ll i=0;i<n;i++)
{
for(ll j=0;j<n;j++)
{
if(i<=j)
{
ll cnt1=0;
for(ll k=0;k<26;k++)
{
ll cnt2=cnt[j+1][k]-cnt[i][k];
if(cnt2>0)
{
char z=k+'a';
// cout<<"char= "<<z<<endl;
cnt1++;
}
}
ld ans=(ld)cnt1/(ld)(j-i+1);
// cout<<"i= "<<i<<" "<<" j= "<<j<<" cnt1= "<<cnt1<<" len= "<<j-i+1<<" ans= "<<ans<<" mi= "<<mi<<endl;
if(mi-ans>0.0000000000)
{
// cout<<"here"<<endl;
mi=ans;
l=i;
r=j;
}
}
}
}
cout<<l+1<<" "<<r+1<<endl;
return 0;
}
Compilation message (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... |