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

#TimeUsernameProblemLanguageResultExecution timeMemory
866430vjudge1Grudanje (COCI19_grudanje)C++17
35 / 70
222 ms524288 KiB
#pragma GCC optimize("unroll-loops,Ofast,O3") #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define spc << " " << #define endl "\n" #define all(x) x.begin(), x.end() #define int long long #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> #define st first #define nd second #define inf 1000000009 #define MOD 1000000007 #define lim 200005 using namespace std; void solve(){ string s; cin >> s; int n=s.size(); string pref[n+1]; pref[0]=s; int q; cin >> q; ii que[q+1]; for(int i=1; i<=q; i++) cin >> que[i].st >> que[i].nd; for(int i=1; i<=n; i++){ int a; cin >> a; pref[i] = pref[i-1]; pref[i][a-1] = '*'; } int cnt[26][n+1]; int l=0, r=n, ans=0; while(l<=r){ int mid = (l+r)/2; for(int i=0; i<26; i++){ cnt[i][0]=0; for(int j=1; j<=n; j++){ cnt[i][j] = cnt[i][j-1]; if((pref[mid][j-1] - 'a') == i) cnt[i][j]++; } } int flag=1; for(int i=1; i<=q; i++){ for(int c=0; c<26; c++){ if(cnt[c][que[i].nd] - cnt[c][que[i].st-1] > 1){ flag=0; break; } } } if(flag){ ans = mid; r = mid-1; } else{ l = mid+1; } } cout << ans << endl; } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); #ifdef Local freopen("in","r",stdin); freopen("out","w",stdout); #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...