Submission #732251

#TimeUsernameProblemLanguageResultExecution timeMemory
732251vjudge1Nivelle (COCI20_nivelle)C++17
110 / 110
236 ms636 KiB
#include<bits/stdc++.h> #define int long long #define MOD 1000000007 #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; int32_t main(){ fast; int n; cin>>n; string s; cin>>s; double mn=1e18; int ans,ans2; for(int i=1;i<=26;i++){ map<char,int>mp; int l=0,r=1,mx=0,x,y; mp[s[0]]++; while(r<n){ if(mp.size()==i){ if(r-l>mx){ mx=r-l; x=l; y=r-1; } mp[s[r]]++; r++; } else if(mp.size()>i){ mp[s[l]]--; if(mp[s[l]]==0)mp.erase(s[l]); l++; } else{ mp[s[r]]++; r++; } } if(mp.size()==i){ if(r-l>mx){ mx=r-l; x=l; y=r-1; } } double a=i; double b=mx; if(a/b<mn){ mn=a/b; ans=x; ans2=y; } } cout<<ans+1<<" "<<ans2+1<<endl; }

Compilation message (stderr)

nivelle.cpp: In function 'int32_t main()':
nivelle.cpp:25:16: warning: comparison of integer expressions of different signedness: 'std::map<char, long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   25 |    if(mp.size()==i){
      |       ~~~~~~~~~^~~
nivelle.cpp:34:21: warning: comparison of integer expressions of different signedness: 'std::map<char, long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   34 |    else if(mp.size()>i){
      |            ~~~~~~~~~^~
nivelle.cpp:44:15: warning: comparison of integer expressions of different signedness: 'std::map<char, long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   44 |   if(mp.size()==i){
      |      ~~~~~~~~~^~~
nivelle.cpp:59:25: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |  cout<<ans+1<<" "<<ans2+1<<endl;
      |                         ^
nivelle.cpp:59:12: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |  cout<<ans+1<<" "<<ans2+1<<endl;
      |            ^
#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...