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

#TimeUsernameProblemLanguageResultExecution timeMemory
1120982steveonalexNivelle (COCI20_nivelle)C++17
110 / 110
26 ms808 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1LL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll gcd(ll a, ll b){return __gcd(a, b);} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ll mask){return __builtin_popcountll(mask);} int ctz(ll mask){return __builtin_ctzll(mask);} int logOf(ll mask){return __lg(mask);} mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b) {a = b; return true;} return false; } template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b) {a = b; return true;} return false; } template <class T> void printArr(T& container, char separator = ' ', char finish = '\n'){ for(auto item: container) cout << item << separator; cout << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } void solve(){ int n; cin >> n; string s; cin >> s; pair<ll, ll> ans = {1e9, 1}, range = {0, 0}; for(int d = 1; d <= 26; ++d){ int freg[26]; memset(freg, 0, sizeof freg); int j = 0; int cnt = 0; for(int i = 0; i<n; ++i){ if (freg[s[i]-'a'] == 0) cnt++; freg[s[i]-'a']++; while(cnt > d){ freg[s[j] - 'a']--; if (freg[s[j] - 'a'] == 0) cnt--; j++; } pair<ll, ll> cur = {cnt, i - j + 1}; // cout << j << " " << i << " " << cur.first << " " << cur.second << "\n"; if (ans.first * cur.second > ans.second * cur.first) { ans = cur; range = {j, i}; } } if (cnt < d) break; } cout << range.first + 1 << " " << range.second + 1 << "\n"; } int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); clock_t start = clock(); solve(); cerr << "Time elapsed: " << clock() - start << "ms!\n"; return 0; }
#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...