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

#TimeUsernameProblemLanguageResultExecution timeMemory
1104185qrnNivelle (COCI20_nivelle)C++14
110 / 110
151 ms768 KiB
#include <bits/stdc++.h> using namespace std; template<class ISqr, class T> ISqr& operator>>(ISqr& is, vector<T>& v) { for (auto& x : v) is >> x; return is; } #define SPEED \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); template <typename T> void show(vector<T> &v) { for (T i : v) { cout << i << ' '; } cout << endl; } #define pb push_back #define ins insert #define fi first #define se second #define endl "\n" #define ALL(x) x.begin(), x.end() #define sz(x) x.size() #define int long long #define _ << " " << #define no cout << "No" << endl; #define yes cout << "Yes" << endl; #define impos cout << -1 << endl; #define vi vector<int> #define pii pair<int,int> #define vpii vector<pii> const int inf = 2e18; const int sze = 5005; void solve() { int n; string s; cin >> n >> s; s = '$' + s; int l = 0, r = 0, ans = 0; for(int sze = 1; sze <= 26; sze++) { map<int,int>cnt; int cur = 0, curl = 1 ; for(int i = 1; i <= n; i++) { cnt[s[i]]++; if(cnt[s[i]] == 1) cur++; while(cur > sze) { cnt[s[curl]]--; if(cnt[s[curl]] == 0) cur--; curl++; } if(ans * (i - curl + 1) > cur * (r - l + 1) || l == 0) { l = curl; r = i; ans = cur; } } } cout << l << " " << r << endl; } signed main(){ SPEED; int t = 1; // cin >> t; for(int cs = 1; cs <= t; cs++) { solve(); } }
#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...