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

#TimeUsernameProblemLanguageResultExecution timeMemory
888093votranngocvyNivelle (COCI20_nivelle)C++14
0 / 110
22 ms604 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int inf = 0x3f3f3f3f; int a[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { char x; cin >> x; a[i] = x - 'a'; } int ans = inf,L,R; for (int i = 1; i <= 26; i++) { vector<int>cnt(30,0); int r = 1,tmp = 0; for (int l = 1; l <= n; l++) { if (l > 1) { cnt[a[l - 1]]--; if (cnt[a[l - 1]] == 0) tmp--; } while (r <= n && tmp < i) { cnt[a[r]]++; if (cnt[a[r]] == 1) tmp++; r++; } if (tmp == i && i * (R - L + 1) > ans * (r - l + 1)) { ans = i; L = l,R = r - 1; } } } cout << L << " " << R << "\n"; }

Compilation message (stderr)

nivelle.cpp: In function 'int main()':
nivelle.cpp:32:36: warning: 'R' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |             if (tmp == i && i * (R - L + 1) > ans * (r - l + 1)) {
      |                                  ~~^~~
nivelle.cpp:32:36: warning: 'L' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...