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

제출 #866424

#제출 시각아이디문제언어결과실행 시간메모리
866424vjudge1Grudanje (COCI19_grudanje)C++17
70 / 70
648 ms4812 KiB
#ifndef Local #pragma GCC optimize("O3,unroll-loops") #endif #include <bits/stdc++.h> #define int long long #define pb push_back #define lim 200000 using namespace std; const int mod=1000000007ll; void solve(){ string s; cin>>s; int n=s.size(); int Q; cin>>Q; pair<int,int>q[Q]; for(auto&qq:q){ cin>>qq.first>>qq.second; qq.first--,qq.second--; } int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; a[i]--; } int l=0,r=n,ans=-1; while(l<=r){ int mid=(l+r)/2; string cur=s; for(int i=0;i<mid;i++){ cur[a[i]]='.'; } map<char,vector<int>>all; for(int i=0;i<n;i++){ all[cur[i]].pb(i); } for(int i=0;i<Q;i++){ for(char c='a';c<='z';c++){ if(!all.count(c))continue; auto&v=all[c]; auto pp=(lower_bound(v.begin(),v.end(),q[i].first)); if(pp==v.end())continue; pp++; int p=(pp!=v.end()?(*pp):n); if(p<=q[i].second){ cerr<<q[i].second<<"\n"; l=mid+1; goto fail; } } } ans=mid; r=mid-1; fail:; } cout<<ans<<"\n"; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #ifdef Local freopen(".in","r",stdin); freopen(".out","w",stdout); #else #endif int t=1; //cin>>t; while (t--) { solve(); } }
#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...