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

#TimeUsernameProblemLanguageResultExecution timeMemory
443701Wasif_JamilGrudanje (COCI19_grudanje)C++14
70 / 70
455 ms12692 KiB
// "Say:He is the Most Merciful,We have believed in him and upon him we have relied" [67:29] #include<bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int q, n = s.size(); cin >> q; vector<pair<int,int>>subwords; for(int i=0; i<q; i++){ int x, y; cin >> x >> y; subwords.push_back({x, y}); } vector<int>v(n); for(int &i:v){ cin >> i; } string ss = s; int l = 0, r = n, ans = n+2; while(l <= r){ int mid = (l+r)>>1; for(int i=0; i<mid; i++){ s[v[i]-1] = '*'; } vector<vector<int>>cnt(26, vector<int>(n)); for(int i=0; i<26; i++){ cnt[i][0] = (s[0] == i+'a'); for(int j=1; j<n; j++){ cnt[i][j] = cnt[i][j-1] + (s[j] == i+'a'); } } int flag = 0; for(auto [first, second]:subwords){ first--, second--; if(first == 0){ for(int i=0; i<26; i++){ if(cnt[i][second] > 1){ flag = 1; } } }else { for(int i=0; i<26; i++){ if(cnt[i][second] - cnt[i][first-1] > 1){ flag = 1; } } } } if(flag == 1){ l = mid + 1; }else { ans = min(ans, mid); r = mid - 1; } s = ss; } cout << ans << '\n'; return 0; }

Compilation message (stderr)

grudanje.cpp: In function 'int main()':
grudanje.cpp:34:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |   for(auto [first, second]:subwords){
      |            ^
#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...