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

#TimeUsernameProblemLanguageResultExecution timeMemory
526789cig32Nivelle (COCI20_nivelle)C++17
110 / 110
36 ms708 KiB
#include "bits/stdc++.h" #define int long long using namespace std; const int MAXN = 1e5 + 10; mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); int rnd(int x, int y) { int u = uniform_int_distribution<int>(x, y)(rng); return u; } int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; double ono = 1e9; int opt_l = 1, opt_r = 1; for(int cnt=1; cnt<=26; cnt++) { int j=0; int freq[26]; for(int i=0; i<26; i++) freq[i] = 0; int distin = 0; for(int i=1; i<=n; i++) { if(i>1) { freq[s[i-2] - 'a']--; if(freq[s[i-2] - 'a'] == 0) distin--; } while(j+1 <= n && distin + (freq[s[j] - 'a'] == 0) <= cnt) { freq[s[j] - 'a']++; if(freq[s[j] - 'a'] == 1) distin++; j++; } if(distin == cnt && i <= j) { if(cnt * 1.0 / (j-i+1) < ono) { ono = cnt * 1.0 / (j-i+1); opt_l = i, opt_r = j; } } } } cout << opt_l << ' ' << opt_r << '\n'; }
#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...