Binlogs
27 subscribers
18 photos
125 links
Download Telegram
I regularly participate in Competitive Programming contests, so from now on I will be giving contest analysis for the questions I solved in those contests here.
Binlogs
https://atcoder.jp/contests/abc412
A.
It was just implementation.

B.
It wanted us to check if every character that comes before an uppercase letter in the first character list, exists also on the second character list.

approach: Store the second character list in set. and check in constant time if the character exists or not.

C.
The question wants us to find a domino list with the minimum number of elements as possible from the provided number list. but there is one condition which is the first element in the domino list should be the first element from the number list and the last element in the domino list should be the last element from the number list.

domino list: its a special list where the current element * 2 is greater than or equal to the next element.

approach: take the first then sort the other elements from the number list except the last element in a new list. then for each element on the output list ( which currently have the first element) find the maximum possible value in which the domino list condition holds up for, then add this new element to the output list and continue. we can find elements in a sorted list with O(logn) time by using binary search. So we do this until we find a case in which the current element * 2 is greater than the last element on the number list.

D.
It was Combination + graph.
Couldn't solve it in time.

#contest_analysis
Binlogs
https://codeforces.com/contests/2123
A.
Alice and Bob are here, and there are n numbers, starting from 0 to n - 1. They take turns taking a number out of the listed ones, alice can choose any of the unchosen numbers and bob can choose any of the unchosen numbers but also the chosen number + what alice chose, must give 3 when doing modulo with 4. They go at it until one them is unable to choose a number.

approach: if n is divisible by 4, then there is always a way for bob to choose a number that satisfies the condition, otherwise alice can win it.

B.
approach: since we choose two elements every time and take the larger one and delete the smaller one, we can delete all the elements except ( the largest number and the value at the index we want), by choosing the largest number and some element to delete. by this technique as long as k > 1, we can retain the number we want.

if k == 1, then our index must be the largest element.

C.
approach: if for the current index, there is a minimum element to its left and there is a maximum element to its right, then its impossible to retain the current index. otherwise, it is always possible.
so we can create a prefix array which stores the current minimum among the current prefixes and create a suffix array which stores the current maximum among the current suffixes. then for each index we can check the condition in constant time and output the result.

D.
approach: the key thing to notice here is that bob can only choose a substring.
if the current number of ones on the string is less than k, then alice can win by choosing them all.
for bob to win there should be more than half number of ones, else alice wins.

E.
approach: find the first index of a 0, even if there are numbers after that they don't matter to the answer.
create a prefix array using the values up to the index. then populate the answer. and that's it.

F.
didn't start it , 'cause of time.

#contest_analysis
Since the contests were many, no #contest_analysis, but here is a recap.
Binlogs
https://atcoder.jp/contests/abc413
was able to solve 4 during contest and finished the 3 that were left after the contest.
Binlogs
https://codeforces.com/contests/2119
I was only able to solve 2 during contest. didn't try it after the contest.
the issue was question B, which I tried but couldn't solve.
Binlogs
https://codeforces.com/contests/2124
I solved 4 during the contest. which is good considering the previous one.
Binlogs
https://atcoder.jp/contests/abc414
A.
check if the current range encapsulates the initial range, and if it does increment the count.

B.
check if the current length of the string plus that is going to be added is greater than 100 or not, if it is stop there and output "Too Long", else put the new characters in to the answer string.

C.
(I couldn't solve it during the contest, one issue was that the code I run on my machine says TLE, but I know that it shouldn't say that, despite knowing that I was trying to come up with a new solution that doesn't say TLE. And It turns out it passes on the site)

Generate all the palindromes up to the given number, then for each number check if it is also a palindrome in the given base, if it is add it to the current sum. finally output the answer.

D.

Sort the list first. we want to add a signal strength such that the total sum of signal strengths is as small as possible. To solve this, we can utilize the gap that exists between the numbers. So if the gap is larger, it is a sign that we should divide the array into two on that point, therefore allowing us to minimize what we have to add. There is an "m" that is given which can be understood as the number of maximum gaps, we have to discard; if we do that the only values that are left are all the minimums and we can just add them and output the result.

E.
Time was not enough. Didn't even read it properly.


#contest_analysis
👍1