(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 #453796

#TimeUsernameProblemLanguageResultExecution timeMemory
453796RGBBNivelle (COCI20_nivelle)C++14
110 / 110
39 ms708 KiB
#include <iostream> #include <bits/stdc++.h> #include <bitset> #include <algorithm> using namespace std; int n,freq[26],d,r,tmax,best[27][3]; string input; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>input; for(int i=1;i<=26;i++) { for(int y=0;y<26;y++)freq[y]=0; d=0; r=0; for(int l=0;l<n;l++) { if(l!=0) { if(freq[input[l-1]-'a']==1)d--; freq[input[l-1]-'a']--; } while(r<n) { if(d==i&&freq[input[r]-'a']==0)break; if(freq[input[r]-'a']==0)d++; freq[input[r]-'a']++; r++; } //cout<<" "<<l<<" "<<r<<"\n"; if(r-l>best[i][0]) { best[i][0]=r-l; best[i][1]=l; best[i][2]=r; } } } //for(int i=1;i<=26;i++)cout<<best[i][0]<<" "<<best[i][1]<<" "<<best[i][2]<<"\n"; double check=0; int oleft=0; int oright=0; for(int i=1;i<=26;i++) { if((double)best[i][0]/(double)i>check) { check=(double)best[i][0]/(double)i; oleft=best[i][1]; oright=best[i][2]; } } cout<<oleft+1<<" "<<oright; }
#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...