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

제출 #891704

#제출 시각아이디문제언어결과실행 시간메모리
891704ind1vGrudanje (COCI19_grudanje)C++11
70 / 70
136 ms26196 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sz(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() #define db(x) cout << "[" << #x << "]: " << x << '\n'; const int N = 1e5 + 4; int a[N], b[N], d[N], p[N]; int pr[N][26]; int n, q; bool m[N]; char x; bool check(int md) { memset(m, 0, sizeof(m)); for (int i = 1; i <= md; ++i) { m[p[i]] = 1; } for (int i = 1; i <= n; ++i) { for (int j = 0; j < 26; ++j) { pr[i][j] = pr[i - 1][j]; } if (!m[i]) { ++pr[i][d[i]]; } } bool f = true; for (int i = 1; i <= q; ++i) { for (int j = 0; j < 26; ++j) { f &= (pr[b[i]][j] - pr[a[i] - 1][j] <= 1); } } return f; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; n = sz(s); for (int i = 1; i <= n; ++i) { d[i] = (int)(s[i - 1] - 'a'); } cin >> q; for (int i = 1; i <= q; ++i) { cin >> a[i] >> b[i]; } for (int i = 1; i <= n; ++i) { cin >> p[i]; } int l = 0, r = n; while (l < r) { int md = (l + r) / 2; if (check(md)) r = md; else l = md + 1; } cout << l; 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...