Submission #844889

#TimeUsernameProblemLanguageResultExecution timeMemory
844889vjudge1Nivelle (COCI20_nivelle)C++17
110 / 110
451 ms856 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 <int, int> mp; int l = 0; for(int j = 0; j <= n; ) { if(mp.size() < i) { if(!mp.count(s[j])) mp.insert({s[j], 0}); mp[s[j]]++; j++; continue; } double val = ((double) mp.size()) / (j - l); if(val < mn) { mn = val; L = l; R = j - 1; } if(!mp.count(s[j])) mp.insert({s[j], 0}); mp[s[j]]++; j++; if(mp.size() > i) { j--; if(mp[s[l]] == 1) mp.erase(s[l]); else mp[s[l]]--; if(mp[s[j]] == 1) mp.erase(s[j]); else mp[s[j]]--; l++; } } } cout<<++L<<" "<<++R<<"\n"; }

Compilation message (stderr)

nivelle.cpp: In function 'int32_t main()':
nivelle.cpp:19:17: warning: comparison of integer expressions of different signedness: 'std::map<long long int, long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   19 |    if(mp.size() < i) {
      |       ~~~~~~~~~~^~~
nivelle.cpp:37:17: warning: comparison of integer expressions of different signedness: 'std::map<long long int, long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   37 |    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...