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

#TimeUsernameProblemLanguageResultExecution timeMemory
447050grtNivelle (COCI20_nivelle)C++17
110 / 110
43 ms716 KiB
#include <bits/stdc++.h> #define PB push_back #define ST first #define ND second #define _ ios_base::sync_with_stdio(0); cin.tie(0); //mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; const int INF = 1e9; int n; string s; int cnt[26]; pi ans = {INF, 1}; pi res; int main() {_ cin >> n >> s; for(int d = 1; d <= 26; ++d) { for(int i = 0; i < 26; ++i) cnt[i] = 0; int j = -1; int mx_len = 0; pi best = {-1,-1}; int dif = 0; for(int i = 0; i < n; ++i) { while(j + 1 < n && dif + (cnt[s[j + 1] - 'a'] == 0) <= d) { cnt[s[j + 1] - 'a']++; dif += (cnt[s[j + 1] - 'a'] == 1); j++; } mx_len = max(mx_len, j - i + 1); if(mx_len == j - i + 1) { best = {i, j}; } cnt[s[i] - 'a']--; dif -= (cnt[s[i] - 'a'] == 0); } //~ cout << d << " " << mx_len << "\n"; if((ll)ans.ST * mx_len > (ll)ans.ND * d) { ans = {d, mx_len}; res = best; } } cout << res.ST + 1 << " " << res.ND + 1; }
#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...