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

#TimeUsernameProblemLanguageResultExecution timeMemory
638272ieeNivelle (COCI20_nivelle)C++17
110 / 110
213 ms11284 KiB
// iee #include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <vector> #include <set> #include <map> #define rep(i, a, b) for (auto i = (a); i <= (b); ++i) #define per(i, a, b) for (auto i = (a); i >= (b); --i) #define fi first #define se second using ll = long long; using ull = unsigned long long; using namespace std; void work(int); template <class T> void read(T &x) { x = 0; int f = 1, ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar(); x *= f; } int main() { int TT = 1; // cin >> TT; rep(CAS, 1, TT) work(CAS); return 0; } const int N = 1e5 + 5; vector<int> pos[26]; int n; double ans = 1e9; int ansl, ansr; char s[N]; int sum[N][26]; void work(int CASE) { scanf("%d%s", &n, s + 1); rep(i, 1, n) pos[s[i] - 'a'].push_back(i); rep(i, 1, n) { rep(j, 0, 25) sum[i][j] = sum[i - 1][j]; sum[i][s[i] - 'a']++; } rep(i, 1, n) { vector<int> hf; rep(j, 0, 25) { auto it = upper_bound(begin(pos[j]), end(pos[j]), i); if (it != end(pos[j])) hf.emplace_back((*it) - 1); } hf.emplace_back(n); sort(begin(hf), end(hf)); for (int t = 0; t < hf.size(); ++t) { int num = 0, j = hf[t], len = j - i + 1; rep(k, 0, 25) num += !!(sum[j][k] - sum[i - 1][k]); if (1.0 * num / len < ans) { ans = 1.0 * num / len; ansl = i; ansr = j; } } } cout << ansl << ' ' << ansr; }

Compilation message (stderr)

nivelle.cpp: In function 'void work(int)':
nivelle.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int t = 0; t < hf.size(); ++t) {
      |                     ~~^~~~~~~~~~~
nivelle.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   scanf("%d%s", &n, s + 1);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
#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...