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

#TimeUsernameProblemLanguageResultExecution timeMemory
930811WhisperNivelle (COCI20_nivelle)C++17
110 / 110
26 ms856 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using str = string; using T = tuple<double, ll, ll>; #define int long long #define Base 31 #define sz(a) (int)a.size() #define FOR(i, a, b) for ( int i = a ; i <= b ; i++ ) #define FORD(i, a, b) for ( int i = b ; i >= a ; i-- ) #define REP(i, n) for ( int i = 0 ; i < n ; ++i ) #define REPD(i, n) for ( int i = n - 1 ; ~(--i) ; ) #define all(x) x.begin() , x.end() #define pii pair<int , int> #define fi first #define se second #define Lg(x) 31 - __builtin_clz(x) constexpr ll LINF = (1ll << 62); constexpr int INF = (1ll << 31); constexpr int MAX = 1e6 + 5; constexpr int Mod = 1e9 + 7; void setupIO( const string& PROB ){ //Phu Trong from Nguyen Tat Thanh High School for gifted student cin.tie(nullptr)->sync_with_stdio(false); cout.tie(nullptr); // freopen( (PROB + ".inp").c_str(), "r", stdin); // freopen( (PROB + ".out").c_str(), "w", stdout); cout << fixed << setprecision(10); } void Whisper(){ int n; string s; cin >> n >> s; s = '$' + s; int L = 1, R = 1; double ans = 1000000000.00; for ( int k = 1 ; k <= 26 ; k++ ){ int l = 1, pl = 0, pr = 0, sz = 0, len = 0; vector<int> cnt(26 , 0); for ( int i = 1 ; i <= n ; i++ ){ while(l < i && sz > k){ --cnt[s[l] - 'a']; if(cnt[s[l] - 'a'] == 0) sz--; l++; } ++cnt[s[i] - 'a']; if(cnt[s[i] - 'a'] == 1) ++sz; if (sz == k){ if (i - l + 1 > len){ len = i - l + 1; pr = i; pl = l; } } } double cur = (double) k / len; if (cur < ans){ L = pl; R = pr; ans = cur; } // cout << k << " " << L << " " << R << " " << ans << '\n'; } cout << L << " " << R << '\n'; } signed main(){ setupIO("Whisper"); int Test = 1; // cin >> Test; for ( int i = 1 ; i <= Test ; i++ ){ Whisper(); if (i < Test) cout << '\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...