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

#TimeUsernameProblemLanguageResultExecution timeMemory
1017208vjudge1Nivelle (COCI20_nivelle)C++17
110 / 110
183 ms756 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; string s; cin >> n >> s; vector<pair<long double, pair<int, int>>> vec; for (int d = 1; d <= 26; d ++){ // cout << "-- " << d << endl; int j = 0; int len = 0; map<char, int> cnt; pair<int, int> best = {-1, -1}; for (int i = 0; i < n; i ++){ cnt[s[i]]++; if (cnt.size() == d){ if (len < (i - j + 1)){ len = i - j + 1; best = {j, i}; } } while (cnt.size() > d){ cnt[s[j]]--; if (cnt[s[j]] == 0) cnt.erase(s[j]); j++; } } if (len == 0) continue; int g = gcd(d, len); double num = d / g; double denum = len / g; // cout << num << " / " << denum << " " << best.first << " -- " << best.second << endl; vec.push_back({num / denum, best}); } sort(vec.begin(), vec.end()); cout << vec[0].second.first + 1 << " " << vec[0].second.second + 1 << endl; }

Compilation message (stderr)

nivelle.cpp: In function 'int main()':
nivelle.cpp:18:28: warning: comparison of integer expressions of different signedness: 'std::map<char, int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |             if (cnt.size() == d){
      |                 ~~~~~~~~~~~^~~~
nivelle.cpp:24:31: warning: comparison of integer expressions of different signedness: 'std::map<char, int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |             while (cnt.size() > d){
      |                    ~~~~~~~~~~~^~~
#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...