By arsijo, 13 months ago, translation,

Hi all!

This weekend, on Oct/06/2019 18:05 (Moscow time) we will hold Codeforces Round 591. It is based on problems of Technocup 2020 Elimination Round 1 that will be held at the same time.

Technocup is a major olympiad for Russian-speaking high-school students, so if you fall into this category, please register at Technocup 2020 website and take part in the Elimination Round.

Div. 1 and Div.2 editions are open and rated for everyone. Register and enjoy the contests!

The Elimination Round authors are BledDest, MikeMirzayanov, Ne0n25, PikMike, Roms, adedalic and me. This round would also be not possible without the help of our testers: KAN, chemthan, gisp_zjz, Kallaseldor, JeffreyHo, danya.smelskiy, Juve45, thank you so much!

Have fun!

UPD.

Unfortunately, the round is unrated.

Tutorial.

• +1254

 » 13 months ago, # |   -40 gisp_zjz Liu HongYang niubi
 » 13 months ago, # |   -65 Why arsijo?
•  » » 13 months ago, # ^ |   -37
•  » » 13 months ago, # ^ |   +15 Why can't arsijo ?That's only a mistake of a contest.
 » 13 months ago, # |   -48 EZ Queueforces..
 » 13 months ago, # |   +52 Oh,come on. Let's enjoy this contest!
•  » » 13 months ago, # ^ |   +26 let's just hope we dont get 20 minutes long queues
 » 13 months ago, # |   +33 A worth-joining contest to end my boring week incredibly <3 <3
•  » » 13 months ago, # ^ |   -64 Get a girlfriend bro
•  » » » 13 months ago, # ^ |   +9 Tomorrow is my girlfriend's birthday anyway :> ~~ An incredible week is cominggg
•  » » » » 13 months ago, # ^ |   0 Hmm nice :). I pray i get one too (^_^). I'll confess to my crush after this contest!!
•  » » » » » 13 months ago, # ^ |   +12 We'll be waiting for your success story then, not heard one in a while. All the best!
•  » » » » » 13 months ago, # ^ |   +5 may loveforces be with you :D
 » 13 months ago, # |   +13 Hope that we are not going to be punished with long queuesJust for not thanking MikeMirzayanov for this awesome platform. XD
•  » » 13 months ago, # ^ |   +3 Even worse this time! xD
 » 13 months ago, # |   +13 Let's hope for clear problem statements
 » 13 months ago, # |   -121 Kindly, after the contest, up-vote this comment if the contest was good, down-vote if it was bad, do not vote if it was mediocre.
•  » » 13 months ago, # ^ |   +43 I am from the Future The contest will be good and your comment will have many downvotes.
•  » » » 13 months ago, # ^ |   0 And you are going to get more up-vote Mr.PaPaSmurf
•  » » » » 13 months ago, # ^ |   0 And you are going to get no votes MR.Mujahid
•  » » » » » 13 months ago, # ^ |   +20
•  » » » 13 months ago, # ^ |   +14 Maybe you are from different universe
 » 13 months ago, # |   -27
•  » » 13 months ago, # ^ |   +20 Why same question every-time when it is mentioned in the description !
•  » » » 13 months ago, # ^ |   +13 It's how who writes this question look like
•  » » 13 months ago, # ^ |   0 This question has become irritating now.
 » 13 months ago, # | ← Rev. 2 →   +39 .
•  » » 13 months ago, # ^ |   +9 All the best Happy Birthday!
 » 13 months ago, # |   +9 It's going to be my first div.1 contest, so excited for that!
•  » » 13 months ago, # ^ |   +13 Your rating graph is so beautiful.
•  » » 13 months ago, # ^ | ← Rev. 2 →   +15 All the best.
•  » » » 13 months ago, # ^ |   -28 Mr.Hasan,you are going to get no votes..Ha ha..
 » 13 months ago, # |   +3 what is rule of contest? ICPC or Codeforces?
 » 13 months ago, # |   0 Have Fun!!! You will be good.
 » 13 months ago, # |   -12 hope arsijo remember the contest he last conducted which was a heck
 » 13 months ago, # |   +8 What will be the Scoring Distribution, no of problems etc ?
•  » » 13 months ago, # ^ |   0 Will be announced later.
 » 13 months ago, # |   +8 Time to go IM
•  » » 13 months ago, # ^ |   +8 Failed.. OTL
 » 13 months ago, # |   0 "All you bug are belong to me" — or how to open problems?
 » 13 months ago, # |   +5 "Independent" QueryForces!
 » 13 months ago, # |   -13 *Me after solving A, B and C"Let's go to comment section"
 » 13 months ago, # |   0 i guess its an unrated contest because of long queue and not being able to access cf
 » 13 months ago, # |   +3 I am not able to submit for last 15 minutes!!
•  » » 13 months ago, # ^ |   +3 30 mins for meI should be unrated
 » 13 months ago, # | ← Rev. 2 →   +18 Go To Hell DDOS Attacker (The Problems Were really nice )
 » 13 months ago, # |   +96 Unfortunately, we had a DDOS attack during the round. Codeforces did not work for a few hours. Obviously, the round will be unrated. Also, there will be an additional Technocup Elimination Round.
•  » » 13 months ago, # ^ | ← Rev. 3 →   -38 .
•  » » 13 months ago, # ^ |   0 Since it is unrated kindly upload the editorial :)
•  » » 13 months ago, # ^ |   0 good
 » 13 months ago, # |   +71 Seems like Codeforces is working again <3This DDoS attack is such a shame, because the contest was quite nice in my opinion. Do we have any idea why would someone do that? (Or if it was a DDoS and not some other issue)
•  » » 13 months ago, # ^ |   -10 Someone who would lose a lot of rating
 » 13 months ago, # | ← Rev. 2 →   +16 "Nice round"
 » 13 months ago, # |   0 I was doing so well in this contest! :( So angry at the ddos attacker. Hopefully the next round is soon.
 » 13 months ago, # | ← Rev. 2 →   0 I would like to submit it quickly. Korea is dawn, but I can't sleep because I wonder the answer is correct. :X
•  » » 13 months ago, # ^ |   +1 Wrong Answer i go to sleep :D
 » 13 months ago, # |   0 F*ck you ddos attacker btw How you solve div2- C ?
•  » » 13 months ago, # ^ |   +8 Binary search, I guess
•  » » » 13 months ago, # ^ |   0 Can you please explain ? :)
•  » » » » 13 months ago, # ^ | ← Rev. 6 →   0 Basically you binary search for the minimum length you can getAnd to test if a length is okYou place the maximum ticket prices at positions where both programs occur i.e. positions divisible by both a and b then the next batch of maximum ticket prices go to positions divisible by a if max(x,y) equals x or b if max(x,y) equals y and the last batch of maximum ticket prices go to positions divisible by a if min(x,y) equals x or b if min(x,y) equals y
•  » » » » » 13 months ago, # ^ |   -8 It's wrong. Get value sequence from 1 to d such that d minimum. not any value @@
•  » » » » » » 13 months ago, # ^ |   0 hien2k.hy I don't understand Can you explain a little more?btw I just submitted and it got accepted
•  » » » » » 13 months ago, # ^ |   +5 your solution is actually correct
•  » » » » » » 13 months ago, # ^ |   +5 Yes I just looked at it again nowThanks Zergrush
•  » » » » 13 months ago, # ^ |   0 Binary search on the number of tickets you will use. You can easily see that if the problem is solvable with k tickets, then it must also be solvable with k+1, and if it is unsolvable with k, it will still be unsolvable with k-1.To check if the problem is solvable for a given K, you have to use the k/lcm(a,b) most expensive tickets on the lcm(a,b) positions, the next most expensive ones will be used for the remaining a and b positions (if x > y use the a positions first, else use the b positions first). This guarantees a maximal value to help the environment.
•  » » » » 13 months ago, # ^ |   0 you can use binary search. first sort the array the then we assume that we need to sold mid ticket and for valid mid we use binary search and in check function u can implement that if we sold the mid number of ticket than profit is more than we reduce right by mid-1 otherwise we increase left by mid+1. At last our answer is mid. you can see the my solution https://codeforces.com/contest/1241/submission/62071599
•  » » » 13 months ago, # ^ |   -8 NO.. It's greedy
•  » » » » 13 months ago, # ^ |   0 Can you explain your logic ?
•  » » » » 13 months ago, # ^ |   +5 U can do binary search
•  » » » » » 13 months ago, # ^ |   0 but how ? Please explain it will be a great help
•  » » » » » 13 months ago, # ^ |   0 Give me your solution
•  » » » » » » 13 months ago, # ^ |   +1 My solution using binary search: Code
•  » » » 13 months ago, # ^ |   0 I solved it with greedy we need to maximize sum we first take maximum values for (x + y) after that we take values to maximum of x and y and then to minimum of x and y
•  » » » 13 months ago, # ^ | ← Rev. 3 →   0 btw i solve it with Greedy and my solution complexity is O(N)so for my solution i put the 3 possibility of discount into a vector in order to ignore i-th index which has no discount: x+y max(x,y) min(x,y) and then i sort the ticket price descending.for each iteration i mark where's the ticket price goes (3 possibility of discount) by putting it into queue. if at i-th iteration the discount is min(x,y) just add the value and put the index into a queue.if at i-th iteration the discount is max(x,y) we move the ticket price at min(x,y)'s queue to max(x,y)'s queue and put the current ticket price in min(x,y)'s queue since the current ticket price is lower than previous ticket price (sort descending)if at i-th iteration the discount is x+y we move max(x,y) to x+y and min(x,y) to max(x,y) and current to min(x,y)example:ticket price : 300 200 100 100discount : 1 1 2 3and here's how the ticket price move for each iteration 300 300 200 100 200 300 100 100 200 300
•  » » » » 13 months ago, # ^ | ← Rev. 2 →   +3 PS: STL sort is O(n log n) so technically your solution isn't O(n)
•  » » 13 months ago, # ^ |   0 Suppose x > y, and the number of tickets sold (call it L) is known in advance, and we just want to know what the optimal profit will be. Let lcm be the least common multiple of a and b.Then the best strategy would be to place your most expensive tickets on multiples of lcm (since this gets you (x+y)%). You can compute how many of those there are in constant time (there are L/lcm of them), and you can use a cumulative sum array to compute the total value of all the tickets in that range (sort the tickets by descending price and sum from 0 to L/lcm). Similarly, place your next most expensive tickets on multiples of a (there are L/a - L/lcm of them), and your least valuable tickets on multiples of b (there are L/b - L/lcm of them), and use the cumulative sum array to get the profit. After you have these quantities, you can compute the total price and compare it to K to see if it satisfies the problem requirements.Now you want to know the minimum L. You can binary search for L, or (since the bounds are low) just do linear search. If you didn't implement the previous paragraph in O(1), you probably need binary search for this part.
•  » » » 12 months ago, # ^ |   0 After putting the maximum priced tickets for x+y shpouldn't we consider a and b along with x and y too? Suppose a is very small so its frequency will be more so won't the optimal way would be to use x because of that even if y>x ?
•  » » 13 months ago, # ^ | ← Rev. 2 →   0 I had a pretty stupid solution. First sorted the list then used 3 queues for type a and b and both. for each length the sum is updated in O(1) with at most 3 push/pops. 62028584
 » 13 months ago, # |   -9 I submited 4 times. -150 points and get last time @@??? why
•  » » 13 months ago, # ^ |   +5 If same code is submitted, its not a problem. Why did you keep changing code?
•  » » » 13 months ago, # ^ |   -9 I use to sv 3 and not show after i submit @@.
 » 13 months ago, # |   +6 How to solve div2-D?
•  » » 13 months ago, # ^ | ← Rev. 2 →   +9 I submitted bottom-up DP. We can show that any element will be moved at most 1 time. So there is exactly 3 options. We either move it to the beggining, move it to the end, or don't touch it. So it's DP[N][3], with DP[i] = minimum amount of turns to sort the first i elements, and [0..2] to denote those 3 options.
•  » » » 13 months ago, # ^ |   +3 Thanks. Nice solution!
•  » » » 13 months ago, # ^ |   +4 can u please explain why dp[i][1]=i in both cases. and why dp[i][2] is same in both cases
•  » » » » 13 months ago, # ^ |   +3 Let's say [1] means move ith element to the left and [2] to the right. If we move ith element to the left, then it will become leftmost element in our array. In that case, the only possible way to sort the first i elements (considering we won't move ith element anymore) is to move the first i — 1 elements to the left, using exactly i turns. And if we move ith element to the right, then we don't care about how we sort the first i — 1 elements, because ith will become the rightmost element, thus it will be the same in both cases.
•  » » » » » 13 months ago, # ^ |   +4 got it!! nice solution
 » 13 months ago, # |   0 From Queueforces to DDOSattackforces. I wasn't lucky at all the last 2 contests :(
 » 13 months ago, # |   +41 Unlucky arsijo... Why problem occurs (!) always in his round?
 » 13 months ago, # |   +6 why the blog doesn't thank MikeMirzayanov to the platform codeforces, maybe this is the issue xD
 » 13 months ago, # |   +41
 » 13 months ago, # |   +1 the statement of the problem Cdiv2 could be shorter . :)i know you probably worked on the statements and you may have a purpose .it was just an advice to shorten the statements as much as you can. :)
 » 13 months ago, # |   +211
•  » » 13 months ago, # ^ |   -8 We need a version of this pic with Mike + CF coordinators. Not just cut+paste in Paint, but some decent work.
 » 13 months ago, # |   +21
 » 13 months ago, # |   +4 Looks like a few people do not see some of their submissions. We are investigating the issue.
 » 13 months ago, # |   +68
•  » » 13 months ago, # ^ | ← Rev. 2 →   0 It refreshes only once in Chrome.
 » 13 months ago, # |   +2 Hope upcoming educational will have nice problems as well!:)
 » 13 months ago, # |   +18 Problem D is very similar to one task from CSAcademy (the only difference is that the given array was a permutation in CSA, but is doesn't really change the solution).
 » 13 months ago, # |   +3 It feels like every rounds kinda DDoS attack, but this time bigger.
 » 13 months ago, # |   +6 In div 1 F, are these random solutions hackable? 62022214 62023134
 » 13 months ago, # |   0 I Was enjoying this round so much that I was reloading every now and then to see the problem getting resolved and never lost hope! Hard Luck arsijo!!
 » 13 months ago, # |   +37 arsijo in your last 2 round, you forgot to thank MikeMirzayanov for platform and polygon. then both of this rounds became unrated !
 » 13 months ago, # |   0 How to solve div1-D?
 » 13 months ago, # |   -19 arsijo's rounds are always unated!
 » 13 months ago, # |   +3 Why are submissions and testcases kept hidden??....Or is this something, only I am facing??
•  » » 13 months ago, # ^ |   0 They are visible to me!
 » 13 months ago, # |   +19 It's probably the most upvoted unrated round.
 » 11 months ago, # |   0 Can someone someone explain problem E (definition of K coloring)?