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

#TimeUsernameProblemLanguageResultExecution timeMemory
969651RandomUserNivelle (COCI20_nivelle)C++17
110 / 110
205 ms1364 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n, P=5000, Q=1, l=1, r=1; string s; cin >> n >> s; map<char, vector<int> > mp; for(int i=0; i<n; i++) mp[s[i]].push_back(i); for(char ch='a'; ch<='z'; ch++) mp[ch].push_back(n); for(int i=0; i<n; i++) { vector<int> v; for(char ch='a'; ch<='z'; ch++) { int p = lower_bound(mp[ch].begin(), mp[ch].end(), i) - mp[ch].begin(); if(mp[ch][p] != n) v.push_back(mp[ch][p]); } sort(v.begin(), v.end()); if(v.back() != n) v.push_back(n); for(int j=0; j<v.size()-1; j++) { int A = j + 1; int B = (v[j+1]-1) - i + 1; if(P * B > Q * A) { P = A, Q = B; l = i, r = v[j+1]-1; } } } cout << l+1 << " " << r+1 << '\n'; return 0; }

Compilation message (stderr)

nivelle.cpp: In function 'int main()':
nivelle.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int j=0; j<v.size()-1; j++) {
      |                      ~^~~~~~~~~~~
#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...