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

#TimeUsernameProblemLanguageResultExecution timeMemory
1112075huantranGrudanje (COCI19_grudanje)C++17
70 / 70
108 ms16204 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long int; const int maxn = 2e5 + 5; const int oo = 1e9 + 7; const ll inf = 1e18; int n, q; string s; int pre[maxn][27], del[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> s; int n = (int)s.length(); s = ' ' + s; cin >> q; vector<pair<int, int>> a(q); for (int i = 0; i < q; i++) cin >> a[i].first >> a[i].second; for (int i = 1; i <= n; i++) cin >> del[i]; int l = 0, r = n; int ans = n; while (l <= r) { int mid = (l + r) >> 1; vector<int> cnt(n + 1, 0); for (int i = 1; i <= mid; i++) { cnt[del[i]]++; } for (int i = 1; i <= n; i++) { for (int j = 0; j < 26; j++) { if ((s[i] - 'a') == j && !cnt[i]) pre[i][j] = pre[i - 1][j] + 1; else pre[i][j] = pre[i - 1][j]; } } int ck = 0; for (int i = 0; i < q; i++) { int ll = a[i].first; int rr = a[i].second; for (int j = 0; j < 26; j++) { if (pre[rr][j] - pre[ll - 1][j] > 1) { ck = 1; break; } } if (ck == 1) break; } if (ck == 0) { ans = mid; r = mid - 1; } else l = mid + 1; } cout << ans; }
#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...