Educational Codeforces Round 153 (Rated for Div. 2) A,B,C Editorial

Revision en3, by Harshit_Raj_14, 2023-08-20 10:13:49

I solved two problems during the contest and upsolved the third one. Here I would like to share my approach in them.

Problem A — Not a Substring Just one simple fact is enough that in the two cases of a valid bracket sequence (((...))) and ()()()... there is only one common substring "()". Otherwise having s in one of them surely makes the other situation our answer t.

Problem B — Fancy Coins This was a very interesting problem and I would like to call my approach a greedy+compromise method. First we act by spending all ak coins, then a1 coins. Then we find the number of fancy coins used as the first case. Another case we deal with is where we compromise by spending lesser a1 coins and more fancyk coins. The minimum of the two situations will be the answer.

Problem C — Game on Permutation The perfect strategy for Alice to win will be a condition a[j]>a[i] for every j<i. And it should occur only once in any subarray. That's the perfect winning strategy for Alice. For that to happen, we take two variables: firstmin(fm) and secondmin(sm). If our current element becomes something like: sm<curr && curr<fm If we find the above condition, then curr is a winning position for Alice, and we will update curr=sm and move forward.

If you want to read a much detailed solution, here's my in-depth written editorial on it — https://medium.com/@Harshit_Raj_14/educational-codeforces-round-153-rated-for-div-2-editorial-a286eda94f5c

Also the codes are available on my github repo — https://github.com/Harshit-Raj-14/My-Codeforces-Solution/tree/main/Educational%20Codeforces%20Round%20153%20(Rated%20for%20Div.%202)

Hope you enjoyed going through the article. You can follow me to get the latest update when I upload more such amazing articles.

Tags editorial, solutions, contest, contribution

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Harshit_Raj_14 2023-08-20 10:13:49 227
en2 English Harshit_Raj_14 2023-08-20 08:28:07 19
en1 English Harshit_Raj_14 2023-08-20 08:25:33 1673 Initial revision (published)