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

#TimeUsernameProblemLanguageResultExecution timeMemory
519261KoDGrudanje (COCI19_grudanje)C++17
70 / 70
149 ms24612 KiB
#include <bits/stdc++.h> using std::vector; using std::array; using std::pair; using std::tuple; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::string S; std::cin >> S; const int N = S.size(); int Q; std::cin >> Q; vector<int> L(Q), R(Q); for (int i = 0; i < Q; ++i) { std::cin >> L[i] >> R[i]; L[i] -= 1; } vector<int> P(N); for (auto& x : P) { std::cin >> x; x -= 1; } int ok = N, ng = -1; array<vector<int>, 26> sum; sum.fill(vector<int>(N + 1)); while (ok - ng > 1) { const int md = (ok + ng) / 2; array<vector<int>, 26> sum; sum.fill(vector<int>(N + 1)); for (int i = md; i < N; ++i) { sum[S[P[i]] - 'a'][P[i] + 1] += 1; } bool f = true; for (int k = 0; k < 26; ++k) { for (int i = 0; i < N; ++i) { sum[k][i + 1] += sum[k][i]; } for (int j = 0; j < Q; ++j) { if (sum[k][R[j]] - sum[k][L[j]] > 1) { f = false; break; } } if (!f) { break; } } (f ? ok : ng) = md; } std::cout << ok << '\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...