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

#TimeUsernameProblemLanguageResultExecution timeMemory
844715vjudge1Nivelle (COCI20_nivelle)C++17
110 / 110
12 ms900 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define pb push_back #define endl '\n' #define fi first #define se second #define fio ios_base::sync_with_stdio(false);cin.tie(NULL); #define CDIV(a,b) (((a)+(b)-(1))/(b)) const ll inf = 1e17 + 5; const ll mod = 1e9 + 7; const ll N = 1e3 + 30; int mod_(int a, int b) { if(a >= 0)return a % b; a += (-a/b + 1) * b; return a % b; } void solve() { int n; string s; cin >> n >> s; int ans_distin = 26, ansl = -1, ansr = -1; vector<int> last(26, -1), in_order(26 + 1, -1); for (int i = 0; i < n; i++) { int c = s[i] - 'a'; in_order.erase(find(in_order.begin(), in_order.end(), last[c])); last[c] = i; in_order.insert(in_order.begin(), i); for (int j = 1; j <= 26; j++) if ((ld)ans_distin / (ld)(ansr - ansl + 1) > (ld) j / (ld) (i - in_order[j])) { ans_distin = j; ansl = in_order[j] + 1; ansr = i; } } //cout << (ld)ans_distin / (ansr - ansl + 1) << ' '; cout << ansl + 1 << " " << ansr + 1 << "\n"; } int main() { fio; //int t; cin >> t; while(t--) { 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...