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

#TimeUsernameProblemLanguageResultExecution timeMemory
199585SamAndGrudanje (COCI19_grudanje)C++17
70 / 70
191 ms13944 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n; char a[N], aa[N]; int q; int l[N], r[N]; int u[N]; int p[N][26]; bool stg(int x) { for (int i = 1; i <= n; ++i) a[i] = aa[i - 1]; for (int i = 1; i <= x; ++i) a[u[i]] = 0; for (int i = 1; i <= n; ++i) { for (int j = 0; j < 26; ++j) p[i][j] = p[i - 1][j]; if (a[i]) ++p[i][a[i] - 'a']; } for (int i = 1; i <= q; ++i) { for (int j = 0; j < 26; ++j) { if (p[r[i]][j] - p[l[i] - 1][j] > 1) return false; } } return true; } int main() { scanf(" %s", aa); n = strlen(aa); scanf("%d", &q); for (int i = 1; i <= q; ++i) { scanf("%d%d", &l[i], &r[i]); } for (int i = 1; i <= n; ++i) scanf("%d", &u[i]); int l = 0, r = n; int ans; while (l <= r) { int m = (l + r) / 2; if (stg(m)) { ans = m; r = m - 1; } else l = m + 1; } printf("%d\n", ans); return 0; }

Compilation message (stderr)

grudanje.cpp: In function 'int main()':
grudanje.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %s", aa);
     ~~~~~^~~~~~~~~~~
grudanje.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
grudanje.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &l[i], &r[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
grudanje.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &u[i]);
         ~~~~~^~~~~~~~~~~~~
#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...
#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...