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

#TimeUsernameProblemLanguageResultExecution timeMemory
866414vjudge1Grudanje (COCI19_grudanje)C++17
70 / 70
539 ms26432 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define sp << " " << #define int long long #define vi vector<int> #define pb push_back #define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++) #define pii pair<int,int> #define ordered_set tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> const int N = 3e5+1; const int MOD = 1e9+7; void solve() { string s; cin >> s; int n = s.size(); int q; cin >> q; vector<pii> ranges(q+1); F(i,q) cin >> ranges[i].first >> ranges[i].second; vi p(n+1); F(i,n) cin >> p[i]; int l = 0; int r = n; while (l<=r) { int m = (l+r) >> 1; vector<bool> fucked(n+1); F(i,m) fucked[p[i]] = 1; vector<vi> pref(26,vi(n+1,0)); F(i,n) { for (int j=0;j<26;j++) pref[j][i] = pref[j][i-1]; if (!fucked[i])pref[s[i-1]-'a'][i]++; } bool fl = 1; for (auto it : ranges) { for (int i=0;i<26;i++) { if (pref[i][it.second]-pref[i][it.first-1] >= 2) { fl = 0; } } } if (fl) r = m-1; else l = m+1; } cout << l << endl; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; //cin >> t; F(i,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...