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

#TimeUsernameProblemLanguageResultExecution timeMemory
887686chanhchuong123Nivelle (COCI20_nivelle)C++14
110 / 110
25 ms656 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() const int MAXN = 1e5 + 4; int n; double ans = 2e9; pair<int, int> pos; char a[MAXN]; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef ngchuong freopen("C.inp", "r", stdin); freopen("C.out", "w", stdout); #endif cin >> n >> (a + 1); for (int k = 1; k <= 26; k++) { int sum = 0; vector<int> cnt(26, 0); for (int l = 1, r = 1; r <= n; r++) { cnt[a[r] - 'a']++; if (cnt[a[r] - 'a'] == 1) sum++; while (sum > k) { if (cnt[a[l] - 'a'] == 1) sum--; cnt[a[l] - 'a']--; l++; } if (sum == k && ans > double(k) / (r - l + 1)) { ans = double(k) / (r - l + 1); pos = {l, r}; } } } cout << pos.fi << ' ' << pos.se; }

Compilation message (stderr)

nivelle.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main() {
      | ^~~~
#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...