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

제출 #223616

#제출 시각아이디문제언어결과실행 시간메모리
223616Haunted_CppGrudanje (COCI19_grudanje)C++17
70 / 70
206 ms13928 KiB
#include <iostream> #include <cstring> #include <algorithm> #pragma GCC optimize ("Ofast") #pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("unroll-loops") using namespace std; const int N = 1e5 + 5; const int Z = 26; int dp [N][Z]; pair<int, int> q [N]; int snow [N]; int main () { ios::sync_with_stdio(0); cin.tie(0); string w; cin >> w; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> q[i].first >> q[i].second; --q[i].first; --q[i].second; } for (int i = 0; i < (int) w.size(); i++) { cin >> snow[i]; --snow[i]; } int lo = 0, hi = (int) w.size(); while (lo < hi) { int mid = lo + (hi - lo) / 2; string cur = w; for (int i = 0; i < mid; i++) { cur[snow[i]] = '*'; } memset (dp, 0, sizeof(dp)); for (int i = 0; i < (int) w.size(); i++) { if (cur[i] != '*') ++dp[i][cur[i] - 'a']; if (i) { for (int j = 0; j < 26; j++) { dp[i][j] += dp[i - 1][j]; } } } bool valid = true; for (int i = 0; i < n; i++) { int baixo = q[i].first; int cima = q[i].second; for (int j = 0; j < 26; j++) { int cnt = dp[cima][j] - (baixo - 1 < 0 ? 0 : dp[baixo - 1][j]); valid &= (cnt <= 1); } } if (valid) hi = mid; else lo = mid + 1; } cout << hi << '\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...