이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5,S=26;
int n,sl,sr,c,len,k,cnt[S];
char s[N];
void add(int x,int v){
x-='a';
if(cnt[x]) k--;
cnt[x]+=v;
if(cnt[x]) k++;
}
int main(){
scanf("%d%s",&n,s+1);
for(int i=1;i<=S;i++) for(int l=1,r=1;l<=n;add(s[l++],-1)){
while(r<=n&&k<=i) add(s[r++],1);
int tr=r-(k>i);
if((tr-l)*c>=len*i) c=i,len=tr-l,sl=l,sr=tr-1;
}
printf("%d %d\n",sl,sr);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
nivelle.cpp: In function 'int main()':
nivelle.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d%s",&n,s+1);
| ~~~~~^~~~~~~~~~~~~~~
# | 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... |