aditraj2004's blog

By aditraj2004, history, 4 months ago, In English

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.

Full text and comments »

  • Vote: I like it
  • -9
  • Vote: I do not like it

By aditraj2004, history, 8 months ago, In English

I was solving the problem https://codeforces.com/contest/1814/problem/C using C++ maps was getting wrong answer on Codeforces submission , was getting the correct answer by compiling and running the same code on the sublime text. I tried Custom Invocation , still was getting wrong answer . I solved the same problem with the same logic using vectors of pair and pair and got accepted solution . I am unable to understand why the solution using maps failed. Problem Link :- https://codeforces.com/contest/1814/problem/C` Submitted Solution using Maps in C++ :- https://codeforces.com/contest/1814/submission/223668739 Accepted Solution using vector : https://codeforces.com/contest/1814/submission/223672537

I thought the issue is happening when the map has only one element , so i tried to cover the case when the map has only one element separately , but still got the same error. The code is failing on this test case :-

n = 5 , s1 = 1 , s2 = 1 value of the array :- 1 1 1 1 1

Forgive me , if i have not expressed my views clearly or haven't explained the question properly because i am new to writting on codeforces

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it