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

#TimeUsernameProblemLanguageResultExecution timeMemory
811152pccGrudanje (COCI19_grudanje)C++14
70 / 70
214 ms16808 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second string s; int n,q; vector<pii> req; bool check(string &t){ vector<int> pref[n+1]; for(auto &i:pref)i = vector<int>(26,0); for(int i = 1;i<=n;i++){ for(int j = 0;j<26;j++)pref[i][j] = pref[i-1][j]; if(t[i] != '#')pref[i][t[i]-'a']++; } //for(int i = 0;i<=n;i++)cout<<pref[i][0]<<' ';cout<<endl; for(auto &i:req){ for(int j = 0;j<26;j++){ if(pref[i.sc][j]-pref[i.fs-1][j] > 1)return false; } } return true; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>s; n = s.size(); s = "#"+s; cin>>q; for(int i = 0;i<q;i++){ int s,e; cin>>s>>e; req.push_back({s,e}); } int mv[n+1] = {}; mv[0] = 0; for(int i = 1;i<=n;i++)cin>>mv[i]; int l = 0,r = n; while(l != r){ int mid = (l+r)>>1; string t = s; for(int j = 1;j<=mid;j++)t[mv[j]] = '#'; //cout<<mid<<":"<<t<<' '<<check(t)<<endl; if(check(t))r = mid; else l = mid+1; } cout<<l; }
#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...