Binlogs
27 subscribers
18 photos
125 links
Download Telegram
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
Binlogs
https://codeforces.com/contests/2125
A.
the question wants to order the string such that "FFT" or "NTT", don't appear as a substring in the string.
approach: take 'F' and 'N' characters to the end of the string.

B.
we're given a, b, and k.
since it only costs us once, when we use a pair of numbers. we can try to find the optimal numbers such that we just have to choose once.
we can get those values by just dividing a and b by their gcd.
then if max(the values we found) is less than or equal to k. we can reach (0, 0) by the cost of 1. else it will take 2.

C.

good integers: integers whose prime factorization only contains numbers that are at least 2 digits.

we are asked to find the number of good integers between l and r.

approach: we can substract the integers that are not good from the total numbers until a particular number.

if we found those numbers for r it means that we found all upto that point. to get the numbers between l and r, we can just substract ("the r one we found from l-1, (because we want the answer that includes l), numbers) and that will be the answer.

How can find the integers that are not good?
since prime factors that are not at least two digits are: 2, 3, 5, 7
we can just find numbers that are divisible by them.
To do that we can use, The inclusion-exclusion principle from mathematics
and that's it.

D.
I read it, but I couldn't understand how the output for the sample testcases were reached.

E.
Understood it, but couldn't come up with an approach.

#contest_analysis
Binlogs
https://atcoder.jp/contests/abc416
A.
manually check if every character that exists between L and R is o.

B.
Essentially what the question is asking us to do is to put only one o character between # characters.

C.
I tried to find a greedy solution for this in which I can just what the sentence is at the x place, which unfortunately failed because of reasons unknown to me.

What most people did was generate all the sentences possible, then sort them then pick the x place.

#contest_analysis
Binlogs
https://codeforces.com/contests/2128?locale=en
A.
we are trying to find the optimal way in which we can choose some numbers in some state so that the total cost would be minimum.
Since after an element is chosen, the other ones are doubled. we can see that if in the current state an element is greater than our c, it will always be greater than our c.

Now let's reverse sort our numbers array, then iterate through it,
while traversing if the current value is greater than our c, then we will add to our cost, but we will not double the other numbers because if it costs us now, that means it will always cost us. thus if we were doing a manual thing we can just choose it at the last right?
But what if the current value is less than or equal to our c, then we can double the rest of the elements because we got a chance to save us some cost on this case. And the rest of the elements after this are all smaller elements so that the likelihood that among the doubled numbers we find an element that is less than or equal to our c is highly likely.

B.
The question wants us to build a new array by either popping an element on the left from the original array or popping an element on the right from the original array, such that the new array we built does not have a 5 sized sub-array which is monotonically increasing or decreasing.

To do that what we can do is build an increasing array until the current increasing order is not 5, by taking the larger element between the left and right of the original array. Now when we reach to a case where the order 4 that means we have to take a lesser number right? thus we just have to choose the minimum between the left and right of the original array. WHY DOES THIS WORK? because we came up until this moment by taking the maximum, therefore the current minimum will always be less than or equal to the previous value we took.

C.

The statement:

Consider an array a1,…,an
. Initially, ai=0
for every i
.

You can do operations of the following form.

You choose an integer x
greater than min(a)
.
Then, i
is defined as the minimum index such that ai<x
. In other words, i
is the unique integer between 1
and n
inclusive such that ai<x
and aj≥x
for every 1≤j≤i−1
.
Finally, ai
is incremented by x
.


given a new array, they want us to find if it is possible to build this array.
The hardest part of this question was to find the likelihood of attaining the current element by using the previous elements as an input.

by analyzing and staring at the computer screen for a while, we can find out that if the current element is greater than (minimum(previous elements) * 2 - 1), then it will be impossible to attain this value else it is always possible.
Now just print "NO" if there is a case that the previous formula fails else print "YES".

D.
I understood it, but I only could come up to a half solution, I was trying to find the other half until time run out.
may be if I started from this question instead of A, I might have been able to solve it.

and that's it.
#contest_analysis
🔥1
Binlogs
https://codeforces.com/contests/2130
A.
the only case in which the mex is better than the other choice is when the subset is made up of 0 (which will be 1).

approach: sum up all the elements except when it is a 0 add 1.

B.

the array is made up of at least one (0, 1, 2). and only consists of (0, 1, 2).

if tot sum of the array is greater than s, then it fulfilled a case where the sum doesn't equal s, so we should output the array.

then if s % the tot is equal to 0, then that means by repeating some amount of time, the other person can get the sum to equal s. thus we should output -1

the last case is when tot < s,

So in this case, we should consider that for our sum to equal s, we have to take the tot, which means touching every element once + taking some segments more than that. the question says that the sum is considered, when we reach the last item, thus from this we establish that, to repeatedly add some elements, we have to at least take two consecutive indices.

for eg, let's say we have [0, 1, 2, 1]
then if I wanted to repeatedly add 1, I can start from index 0 and stop at index 1, because if I move to the left I always have to move to right, since we always should end up at the last item.

based on this here are some numbers in which the sum can be,
if we take (0, 1) -> 1, (1,2) -> 3, (0, 2) -> 2, and the possible necessary combinations: (0, 1, 2), I can get 1 and 3 from this.
(0, 2, 1), I can get 2 and 3 from this.
(1, 0, 2), I can get 1 and 2 from this.

so I always get two choices, right and If I choose the case where I get 1, then I can repeat 1 as many times as I want and I can reach the sum I want.

so the only case in which I can't get the sum I want is when the sum I want is 1 and the array I have is [0,.....,0,2,....,2,1,...,1], in any other case I ( they as per the question since I'm trying to create a case in which the one who does the sum fails), can always get the sum I want.


C.

why don't we consider this, if the difference between a and b is large, I can get a lot of numbers for the first case, also if they are not in any cycle, when we do the second case, that means I got the maximum possible difference between f(s) and g(s),

the solution can be found by being greedy,

Sort the tuples, in descending order based their difference, then one by one build a graph, and if the current tuple creates a cycle in the graph, skip it. ( we can use UnionFind for this), else append the index of the current tuple in the original given order to the output array.


D.

understood it. I took some time to come up with approaches, but couldn't
some rant


and when I checked the time, it was around 1:00 L.T. and I thought there is only 30 minutes left. then gave up and went for dinner, by the time I come back to check the standings, it says 11 min left. turns out the contest was 3 hours long, not like 2 hours as the usual. still didn't solve it.


#contest_analysis


what about your approaches?
👍1