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

#TimeUsernameProblemLanguageResultExecution timeMemory
199515SamAndNivelle (COCI20_nivelle)C++17
110 / 110
101 ms10744 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n; char a[N]; int u[N][26]; int main() { scanf("%d", &n); scanf(" %s", a); for (int j = 0; j < 26; ++j) u[n][j] = n; for (int i = n - 1; i >= 0; --i) { for (int j = 0; j < 26; ++j) u[i][j] = u[i + 1][j]; u[i][a[i] - 'a'] = i; } int x = N, y = 1; int ansl = -1, ansr = -1; for (int l = 0; l < n; ++l) { sort(u[l], u[l] + 26); for (int j = 0; j < 26; ++j) { int r; if (j < 25) r = u[l][j + 1] - 1; else r = n - 1; if ((j + 1) * y < x * (r - l + 1)) { x = (j + 1); y = (r - l + 1); ansl = l; ansr = r; } } } printf("%d %d\n", ansl + 1, ansr + 1); return 0; }

Compilation message (stderr)

nivelle.cpp: In function 'int main()':
nivelle.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
nivelle.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %s", a);
     ~~~~~^~~~~~~~~~
#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...