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

#TimeUsernameProblemLanguageResultExecution timeMemory
347103Pichon5Grudanje (COCI19_grudanje)C++17
70 / 70
378 ms13988 KiB
#include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair //salida rapida "\n" //DECIMALES fixed<<sp(n)<<x<<endl; //gcd(a,b)= ax + by //lCB x&-x //set.erase(it) - ersases the element present at the required index//auto it = s.find(element) //set.find(element) - iterator pointing to the given element if it is present else return pointer pointing to set.end() //set.lower_bound(element) - iterator pointing to element greater than or equal to the given element //set.upper_bound(element) - iterator pointing to element greater than the given element // | ^ using namespace std; string s; int n; int q; pair<int,int>Q[100005]; vi v(100005); bool ok(int mid){ string ss=s; for(int i=1;i<=mid;i++){ ss[v[i]]='*'; } int M[26][n+5]; for(int i=0;i<26;i++){ M[i][0]=0; } for(int i=1;i<=n;i++){ for(int l=0;l<26;l++){ M[l][i]=M[l][i-1]; } if(ss[i]=='*')continue; M[ss[i]-'a'][i]++; } for(int i=1;i<=q;i++){ int L=Q[i].F,R=Q[i].S; for(int l=0;l<26;l++){ if(M[l][R]-M[l][L-1]>1){ return false; } } } return true; } int main() { cin>>s; n=s.size(); s='.'+s; cin>>q; int a,b; for(int i=1;i<=q;i++){ cin>>a>>b; Q[i]={a,b}; } for(int i=1;i<=n;i++){ cin>>a; v[i]=a; } int e=n;b=0; int res=0; while(b<=e){ int mid=(b+e)/2; if(ok(mid)){ res=mid; e=mid-1; }else{ b=mid+1; } } cout<<res<<endl; 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...