Binlogs
27 subscribers
18 photos
125 links
Download Telegram
There's a difference between knowing the perfect recipe for a roast chicken and having the skill to debone one in sixty seconds.
comments
Binlogs pinned «https://odinwhereswaldo.netlify.app #myprojects»
AKS algorithm, that is used to test the primality of a number in O(log(n)^7.5)

#YIL
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