| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 462480 | Jasiekstrz | Nivelle (COCI20_nivelle) | C++17 | 44 ms | 708 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 fi first
#define se second
using namespace std;
const int N=1e5;
struct Ans
{
int l,r;
int a,b;
bool operator<(const Ans &oth) const
{
return a*oth.b<oth.a*b;
}
};
int cnt[300];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
string s;
Ans ans={1,1,1,1};
cin>>n>>s;
for(int c=1;c<='z'-'a'+1;c++)
{
for(int i=1,j=0,tmp=0;i<=n;)
{
if(j<n && tmp<=c)
{
j++;
cnt[s[j-1]]++;
if(cnt[s[j-1]]==1)
tmp++;
}
else
{
cnt[s[i-1]]--;
if(cnt[s[i-1]]==0)
tmp--;
i++;
}
ans=min(ans,(Ans){i,j,tmp,j-i+1});
}
}
cout<<ans.l<<" "<<ans.r<<"\n";
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... | ||||
