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

#TimeUsernameProblemLanguageResultExecution timeMemory
462480JasiekstrzNivelle (COCI20_nivelle)C++17
110 / 110
44 ms708 KiB
#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; }

Compilation message (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 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...