이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
nivelle.cpp: In function 'int main()':
nivelle.cpp:32:15: warning: array subscript has type 'char' [-Wchar-subscripts]
32 | cnt[s[j-1]]++;
| ^
nivelle.cpp:33:18: warning: array subscript has type 'char' [-Wchar-subscripts]
33 | if(cnt[s[j-1]]==1)
| ^
nivelle.cpp:38:15: warning: array subscript has type 'char' [-Wchar-subscripts]
38 | cnt[s[i-1]]--;
| ^
nivelle.cpp:39:18: warning: array subscript has type 'char' [-Wchar-subscripts]
39 | if(cnt[s[i-1]]==0)
| ^
# | 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... |