Submission #844875

#TimeUsernameProblemLanguageResultExecution timeMemory
844875vjudge1Nivelle (COCI20_nivelle)C++17
0 / 110
61 ms640 KiB
#include <bits/stdc++.h> #define fast cin.tie(0)->sync_with_stdio(0); #define int long long #define inf ((int)1e18) #define N 200005 using namespace std; int32_t main(){ fast int n; cin>>n; string s; cin>>s; double mn = 100, L = 0, R = 0; for(int i = 1; i <= min(n, 26ll); i++) { map <char, int> mp; mp.insert({s[0], 1}); int l = 0; for(int j = 1; j < n; j++) { if(mp.size() < i) { if(!mp.count(s[j])) mp.insert({s[j], 0}); mp[s[j]]++; if((double)mp.size() / (j - l + 1) < mn) { mn = (double)mp.size() / (j - l + 1); L = l, R = j; } continue; } //mp.size() == i if(!mp.count(s[j])) { if(mp[s[l]] == 1) mp.erase(s[l]); else mp[s[l]]--; l++; j--; continue; } if((double)mp.size() / (j - l + 1) < mn) { mn = (double)mp.size() / (j - l + 1); L = l, R = j; } } } cout<<++L<<" "<<++R<<"\n"; }

Compilation message (stderr)

nivelle.cpp: In function 'int32_t main()':
nivelle.cpp:20:17: 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]
   20 |    if(mp.size() < i) {
      |       ~~~~~~~~~~^~~
#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...