(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #638273

#TimeUsernameProblemLanguageResultExecution timeMemory
638273RegisterNivelle (COCI20_nivelle)C++14
110 / 110
34 ms460 KiB
#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; }

Compilation message (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...