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

#TimeUsernameProblemLanguageResultExecution timeMemory
499297inksamuraiNivelle (COCI20_nivelle)C++17
110 / 110
188 ms14124 KiB
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() #define rep(i,n) for(int i=0;i<n;i++) #define crep(i,x,n) for(int i=x;i<n;i++) #define drep(i,n) for(int i=n-1;i>=0;i--) #define vec(...) vector<__VA_ARGS__> #define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; typedef long long ll; typedef long double ld; using pii=pair<int,int>; using vi=vector<int>; using vll=vector<long long>; int main(){ _3qplfh5; int n; cin>>n; vi a(n); rep(i,n){ char ch; cin>>ch; a[i]=ch-'a'; } vec(vi) prv(n,vi(26,-1)); ld ans=1e9; pii p={-1,-1}; auto affine=[&](int cnt,int l,int r){ ld x=cnt,y=r-l+1; if(x/y<ans){ ans=x/y; p={l,r}; } }; vi usd(26,0); rep(i,n){ int ch=a[i]; if(i) prv[i]=prv[i-1]; prv[i][ch]=i; usd=vi(26,0); usd[ch]=1; int j=i,cnt=1; while(true){ int ma=-1; rep(nech,26){ if(prv[j][nech]!=-1 and usd[nech]==0){ if(prv[j][nech]>ma){ ma=prv[j][nech]; } } } if(ma==-1){ affine(cnt,0,i); break; } j=ma; affine(cnt,j+1,i); usd[a[j]]=1; cnt++; affine(cnt,j,i); } } // cout<<ans<<"\n"; cout<<p.fi+1<<" "<<p.se+1<<"\n"; // return 0; }
#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...