Codeforces Round 942 (Div. 1, Div. 2) Editorial
source link: https://codeforces.com/blog/entry/129027
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
1967B1 - Reverse Card (Easy Version)
1967B2 - Reverse Card (Hard Version)
1967D - Long Way to be Non-decreasing
1967E1 - Again Counting Arrays (Easy Version)
1967E2 - Again Counting Arrays (Hard Version)
Thanks A_G for discovering that E2 is possible!
too math, downvoted... |
4 hours ago, # | I don't think that this round deserves hate. div2A-D2 were all good. I say that as someone stuck on D2 for almost 2 hours. My final submission was rejected because of strict limits. However, the trick can compensate for it. I find it fascinating, and I am glad to have seen it. The model code is much simpler than mine. The downside is that all problems (the ones I attempted) had the same (math) tag. But, it is a common trend nowadays. We cannot do anything about it, so cope. |
Well, here is the main contribution list of the writers.
Please feel free to tell us which is you favourite problem and why, and even the problems you dislike too. Meanwhile, I would also like to thank our hard-working coordinator and testers. They together made it possible for us to hold this round. If there is a chance, we hope to meet again with better problems. |
-
D1 is not mine, it was accidentally invented by the tester newb_programmer while he was solving D2.
can anyone explain, why my code is WA on test 7 (problem B)
|
-
Inadequate char array length.
-
but why? its size is n
4 hours ago, # | Whoa did not expect the solution to B would be so simple |
4 hours ago, # | is it possible to solve 2C/1A using Priority Queue? Not in . I din't think of binary search and now my Pupil is on the line :sob: |
-
-
can you explain please?
-
Here curr is storing the minimum value all the elements can reach and rem stores the remaining operations after that minimum value is reached. Every element in priority queue I am comparing with previously reached value and calculating whether it possible to reach next top of priority queue value with remaining k.
-
-
4 hours ago, # | weak pt. I just wrote the limit as the correct limit -1. |
4 hours ago, # | Could solve all the way to the problem D2. My math knowledge was useful in both task D1 & D2, however, mathforces. |
4 hours ago, # | Editorial is Little bit confusing for me. Please can anyone verify that following approach was correct? 1)sort array use binary search, to make all all element atleast equal to X This x will have range from min of array to max+k of array.. 2)then ..make arrangement,1->n in this cycle and calculate the answer...using this x |
-
You don't need binary search if you already sorted array.
- Find = number full permutations (bin search or sort + prefix sum)
- = remaining k
- add (and purchase distinct ) at any end of full permutations to form additional permutations of .
in div2D1 you do not have to count using math, you can naively run a for loop. The time complexity will be still for each test case. This is because, for each value of the loop will take time, and converges to . |
-
We can also notice that must be a multiple of and iterate from and from , then it turns into .
-
Unfortunately couldn't make the same trick work for Div2D2, do you have any idea how?
-
4 hours ago, # | My O(n log^3 n) solution has passed the Div1B2, can anyone hack it or give a tighter complexity? |
4 hours ago, # | Nice maths training contest |
Can anyone give me the reason why this got signed integer overflow 258927405. I have checked the code it and it is correct for other ranges,but fails here. |
4 hours ago, # | As far as I'm concerned, E is a bit classical and similar to CF837F. By the way, thanks anyway to this round that made me GM. |
4 hours ago, # | A different solution to div1. A, div2. C using binary search. The answer is completely binary searchable and there isn't anything wrong with it, but it doesn't match my intuition. Let binary search on the number of Full permutations you create, we can handle the remaining part manually with an O(n), in binary search, let's check if we can have full permutations created, to check it we can just calculate the need for that much permutation for each item and see if have more or less if we had less we just add the the code: 258927507 |
4 hours ago, # | |
4 hours ago, # | OMG D2... I got: So, I decided to sum up them and get: Nice contest though |
4 hours ago, # | Loved the round, thank you! The best moment of the contest for me was when I started coding Persistent Segment Tree in Div.1 D (it wouldn't have worked probably) and realized that there's a cute solution with much less code! Though E1 looks like a pretty standart problem to be honest... |
4 hours ago, # | For 1972C - Permutation Counting, I first misread the problem as to find the maximum possible answer for any , where the subarrays form permutations of . 258892957 I'm not sure if that was the right approach for the misread verison, but after realizing my mistake, simply disabling the outer loop to handle only case made it AC. 258896138 Would've been great for me if the problem was actually about the misread one :) |
4 hours ago, # | Very good math problems and fast editorial. Thanks! |
4 hours ago, # | I am a newbie and I intend to reach to pupil quickly.What resources should I follow to reach it and I really feel annoyed with questions like B that was asked today.I tend to spend a lot of time on such problems and many a times contest gets ended and I am unable to come up with solution.Please guide me |
-
Take a look at the codeforces catalog. There people much smarter than me have posted the exact thing you are looking for.
From resources to guides on how to improve and tutorials on specific topics and even stuff on mindset and attitude.
I like Div1E, thanks, though I couldn't make it on time...(QAQ) Here is my solution. We can rephrase the problem as a random walk:
If we had infinite number of steps instead of , the problem would be classical. Let be the probability that, starting from , it is eventually absorbed at after infinite number of steps. We have . It is known that for and for . (Caveat: What if divides the denominator? It turns out no such case exists within the constraints, luckily.) To compute of for , we can reduce it to certain path counting and use reflection method as in the editorial. It takes time for each , thus overall. (Caveat: The sum of is not bounded! We should do this only for .) |
Lol, I thought about the model solution to E1, but also thought "Huh? quite weird tradeoff solution with a ton of detailed math? I'm not coding that for 1750 points! There must be some much slicker way to do this!" and that turned out to be exactly the intended solution xD... But I managed to get D instead and I wouldn't be able to do both anyway |
2 hours ago, # | Could anyone explain the output of this test case for the div2C problem? 1 9 1 2 1 5 7 5 3 3 The answer is 27 but I am only getting 26 as max. [6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10] |
116 minutes ago, # | I have made detailed video explanations for C and D1 Question Here are the links for anyone who wishes to watch C : https://www.youtube.com/watch?v=ZP4HPYTWtZQ D1 : https://www.youtube.com/watch?v=cSKooXv7FKA |
43 minutes ago, # | can anyone help me finding what's wrong with this approach in 2/C |
-
Inside the binary search, you can break when
tmp < 0
(clearly). Turns out, you "must" break otherwise some negative integer overflow will occur and unintentionally make tmp positive even though it should DEFINITELY be negative oncetmp < 0
occurred. I got AC on your submission with this change. 258943287
3 minutes ago, # | We can also solve Div1C in by maintaining the generating function for every position , where denotes the value of where is the array we are trying to find and is the "fenwick function" from the statement. We maintain it by processing 's in the ascending order of their lowest bit and summing up the generating functions. The result can be extracted as . |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK