(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.

제출 #198278

#제출 시각아이디문제언어결과실행 시간메모리
198278alradGrudanje (COCI19_grudanje)C++17
70 / 70
489 ms17072 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base :: sync_with_stdio(0); cin.tie(0) , cout.tie(0); string s; cin >> s; const int n = (int)s.size(); int q; cin >> q; vector<pair<int , int> > sub(q); for (int i = 0; i < q; i++) { int a , b; cin >> a >> b; sub[i] = {a , b}; } vector<int> p(n); for (int i = 0; i < n; i++) { cin >> p[i]; } auto can = [&](int tot) { vector<bool> used(n , false); for (int i = 0; i < tot; i++) { used[p[i]] = true; } vector<vector<int> > let(n + 1 , vector<int>(26 , 0)); for (int i = 1; i <= n; i++) { if (!used[i]) { let[i][int(s[i - 1] - 'a')]++; } for (int j = 0; j < 26; j++) { let[i][j] += let[i - 1][j]; } } for (int i = 0; i < q; i++) { int L = sub[i].first , R = sub[i].second; for (int j = 0; j < 26; j++) { if (let[R][j] - let[L - 1][j] >= 2) { return false; } } } return true; }; int l = 0 , r = n; while (l != r) { int mid = (l + r) >> 1; if (can(mid)) r = mid; else l = mid + 1; } cout << r << '\n'; return 0; }
#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...