Блог пользователя aditraj2004

Автор aditraj2004, история, 5 месяцев назад, По-английски

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.

  • Проголосовать: нравится
  • -9
  • Проголосовать: не нравится

»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by aditraj2004 (previous revision, new revision, compare).

»
5 месяцев назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Maybe this testcase will help:

1
abaaba
2
baab
aba
2
2 1
2 4