Why My Algorithm doesn't work in Problem D of contest Codeforces 811 Div 3

Revision en2, by aditraj2004, 2024-01-20 07:35:35

Question Id :- 1714D - Color with Occurrences

Wrong Submission Link :- 242502092

In Problem D ,why does the algorithm in which selecting the word from which maximum red letters occurs in string s in a given step doesn't work.. According to my understanding .. If we don't pickup the substring of s in which maximum occurence of red happens in a step , then we can always pick it up later if the substrings of current picking doesn't intersect with the substring in which the maximum red occurence happens in a particular step. And if the substring intersect , then still we can swap the positions of picking of a substring in which maximum red characters appear in a step , the number of reds will decrease by the same. But , if one string is a substring in the strings in which we have to make it red. then picking the string with maximum red happens in a step is still optimal ..

So , Why at each step just applying the operation with the string k[i] (1 <= i <= k) , in which the maximum new red characters which happen in a operation in string s is wrong.

Implementation of the Algorithm :- In the submission Link.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English aditraj2004 2024-01-20 07:35:35 8 Tiny change: 'ptimal .. So , at each s' -> 'ptimal .. \n\nSo , Why at each s'
en1 English aditraj2004 2024-01-20 07:20:43 1198 Initial revision (published)