By Dormi, 2 weeks ago,

Hello, Codeforces!

Welcome to the Codeforces LATOKEN Round 1 (Div. 1 + Div. 2) supported by LATOKEN, that will start on Jun/13/2021 18:35 (Moscow time). It will be a combined rated round for both divisions (and div 3). Please, note the unusual start time.

All problems were created by Aaeria, crackersamdjam, Dormi, Ninjaclasher, and Plasmatic.

We would like to thank:

You will be given 8 problems and 180 minutes to solve them. This contest features at least one interactive problem, so we recommend reading the guide of interactive problems before the contest.

We hope that statements are short and pretests are strong and that you find the problems interesting! Good luck, have fun, and we wish everyone high ratings!

The scoring distribution will be announced closer to the beginning of the round.

Thanks to LATOKEN, winners will get awesome swag:

• 1st place = MacBook Air M1 + Job offering and Stock Options
• 2nd place = Xiaomi Mi 11 + Job offering and Stock Options
• 3rd place = Xiaomi Mi Notebook Pro 15" Enhanced Edition + Job offering and Stock Options
• 4th-10th place = Job offering and Stock Options + Merchandise Pack
• 11th-55th place = Merchandise Pack

Random 10 participants outside of top-55, who solved at least one problem and participated in rated Codeforces rounds before, will get a t-shirt!

A few words from the LATOKEN team:

We welcome you to the intellectual battle between the best coders from around the world! LATOKEN strives to make trading crypto as easy as having a social media account. We are always looking for the best of the best to join our team. As a result, LATOKEN is currently in Coingecko’s Top 15 with over 600 000 app installs within just one year from its launch and 1m+ users in total. The emerging blockchain based financial systems will open exciting opportunities, because crypto is fully global and mostly independent of conservative banks.

If you want to become a part of something bigger, work remotely with a team of international professionals and change the world, contact our recruiters for internships and employment opportunities in the LATOKEN team. Use our bot or fill out the form below and tell us a little about yourself.

Bot→
Contact Form →

UPD: The scoring distribution is 500 — 1000 — 1250 — 1500 — 2250 — (1750 — 1250) — 3250 — 3500.

UPD: Editorial

Congratulations to the winners:

The prizes will be distributed in the next few days after we remove cheaters.

• +623

 » 2 weeks ago, # | ← Rev. 2 →   +116 Do the contest or TLE real life
•  » » 13 days ago, # ^ |   -7
•  » » 12 days ago, # ^ |   0 ORZZZZ
 » 2 weeks ago, # |   +103 As a tester, the problems are great, as always. I hope you enjoy one of the first Canadian rounds!
•  » » 2 weeks ago, # ^ |   +210
•  » » » 2 weeks ago, # ^ |   +36 Leaf -> 100%
•  » » 2 weeks ago, # ^ |   +6 finally your round is here!, excited for the C problem. PurpleCrayon ORZ
 » 2 weeks ago, # |   +193
 » 2 weeks ago, # |   -24 Mandatory "tourist, What will you do with your MacBook Air M1?" comment.
 » 2 weeks ago, # |   +180 I was just wondering why 1st-3rd placed participants are not being offered the job while 4th-10th are XD.
•  » » 2 weeks ago, # ^ |   +124 FAANG already hired them.
•  » » 12 days ago, # ^ |   +3 They are the real thugs, they can live with winning cash prizes in big coding contests.
 » 2 weeks ago, # |   +5 He is Valentin Preobrazhenskiy not Valentine.
 » 2 weeks ago, # | ← Rev. 4 →   +17 "Random 10 participants outside of top-55, who solved at least one problem and participated in rated Codeforces rounds before, will get a t-shirt!" Am I going to be the one of those 10 ? rounding up number of people solving atleast 1 problem to 20000 as we have 3 hours given probaility is ( 1/(20000)), . It comes out to be (0.00005)
•  » » 12 days ago, # ^ |   +10 Well almost, you need to multiply 0.00005 by 10, because "Random 10 participants outside of top-55...". So that's 0.00005*10 = 0.0005. But I don't think it changes anything)
 » 2 weeks ago, # |   -21 be annoy of the suck statement at last several round.statements are short look forward to this round.
•  » » 2 weeks ago, # ^ |   +4 I was wondering why your rating graph is like this!!!
•  » » » 2 weeks ago, # ^ |   +3 yep, I was graduated several year, now i want CF agin!!!
 » 2 weeks ago, # |   -24 PurpleCrayon orz
 » 2 weeks ago, # |   -26 Unfortunately, the start time is 11.35 PM in my area :(
•  » » 2 weeks ago, # ^ |   +47 thank you for useful and interesting comment
 » 2 weeks ago, # |   +65
 » 2 weeks ago, # |   +34 As a tester I must say the problems are nice and interesting. May you all get a positive delta.
 » 2 weeks ago, # |   +3 If you forgot to see the prizes section of the post.Do visit again!
•  » » 2 weeks ago, # ^ |   0 No
 » 2 weeks ago, # |   -21 very weird time :|
 » 2 weeks ago, # |   -11 Not interactive again
 » 2 weeks ago, # |   0 Codeforces if True Love.
 » 2 weeks ago, # |   +94 Just switched from Instagram to Codeforces, a few days back, and trust me Codeforces is much better.
•  » » 12 days ago, # ^ |   0 Teach me senpai!
 » 2 weeks ago, # |   -33 note the unusual start time
•  » » 2 weeks ago, # ^ |   -17 is't it unusual.. i know you guys are downvoting just because i am pupil
•  » » » 2 weeks ago, # ^ |   +21 correlation =/= causation
•  » » » » 2 weeks ago, # ^ |   +2 ≠
•  » » » » » 13 days ago, # ^ |   +3 !=
•  » » » » » » 13 days ago, # ^ |   +20 !(a ^ b)
 » 2 weeks ago, # | ← Rev. 2 →   +69 4th-10th place = *Job offering* and Stock Options + Merchandise PackI want this level of confidence in my life.
 » 2 weeks ago, # | ← Rev. 2 →   -24 This forces us to stay up late in night. :(
 » 2 weeks ago, # |   +21 I will sleep during the round. Spoiler
 » 2 weeks ago, # |   -26 Another MacBook for tourist
•  » » 2 weeks ago, # ^ |   0 lol
•  » » 2 weeks ago, # ^ |   0 TO be Honest I was searching for this comment Lol!!
 » 2 weeks ago, # | ← Rev. 3 →   -23 Codeforces is the best ❤️
•  » » 2 weeks ago, # ^ | ← Rev. 2 →   +36 Nevermind
 » 2 weeks ago, # |   -74 Is it rated?
 » 2 weeks ago, # |   +2 Sorry I'm getting back to CF after many years and now I see there is also a Div3. Will this round also be rated for Div3 folks?
•  » » 2 weeks ago, # ^ | ← Rev. 2 →   +20 Yes, there is pretty much no div3 as such. Anyone who's a div3 is also a valid div2
•  » » 2 weeks ago, # ^ |   0 As now there's also a Div4 you're Div4. But all contests of higher divisions than your division are rated for you. Unless round has separate contests for separate divisions. Because then you can only participate in your division contest.
•  » » » 13 days ago, # ^ |   +2 his ranks say otherwise, he'll soon reach expert
•  » » » » 12 days ago, # ^ |   +5 Thanks! I hope so too. I aim to reach Div1 sometime in the next few months. Let's see how it goes.
 » 2 weeks ago, # |   -47 Just switched from Instagram to Codeforces, a few days back, and trust me Codeforces is much better.
•  » » 2 weeks ago, # ^ |   +18 Memes with more class; comments with more sass
 » 2 weeks ago, # | ← Rev. 2 →   0 I guess top gear isn't popular here :/
•  » » 2 weeks ago, # ^ |   0 not funny didnt laugh
•  » » » 2 weeks ago, # ^ | ← Rev. 3 →   +8
•  » » » » 2 weeks ago, # ^ |   +5 if I didn't laugh doesn't mean anyone won't. No need deleting it
 » 2 weeks ago, # |   -12 wannahavealife 1000-7 ? ? ? ?
•  » » 2 weeks ago, # ^ |   0 993-7 ? ? ?? ? ?? ? ? ?
•  » » » 2 weeks ago, # ^ |   0 986-7 ?????????????❓❓❓❓❓❓
•  » » » » 2 weeks ago, # ^ |   +21 979-7 ????????????
•  » » » » » 2 weeks ago, # ^ |   -8 972-7
•  » » » » » » 2 weeks ago, # ^ |   -10 965-7????????????
•  » » » » » » » 2 weeks ago, # ^ |   -26 ¿958-7?
•  » » » » » » » » 13 days ago, # ^ |   -20 ?????? 952-7?????
 » 2 weeks ago, # |   0 it will be unrated for div 3??
•  » » 2 weeks ago, # ^ |   -30 Yes this round is unrated for all divisions greater than 2
•  » » 13 days ago, # ^ |   0 no
•  » » 13 days ago, # ^ |   +7 It will be a combined rated round for both divisions (and div 3).
•  » » 13 days ago, # ^ |   +11 div3 is a subset of div2
 » 2 weeks ago, # |   0 A couple more years and I can finally win a prize. (Hopefully)
 » 2 weeks ago, # |   +156 Seems codeforces finally realized nobody reads this rules anyways, so they just removed it lol
 » 2 weeks ago, # |   -15 This contest is rated for division 3 or not?Any please replay
•  » » 2 weeks ago, # ^ |   +17 Yes
•  » » » 2 weeks ago, # ^ |   0 Thanks for your fast reply
•  » » » » 13 days ago, # ^ |   +5 So are you gonna participate or not? Just curious about the effect that being rated causes on participation.
•  » » » » » 13 days ago, # ^ |   0 I will definitely participate in this contest .
•  » » 2 weeks ago, # ^ |   +1 Every div3 member is also considered a part of div2 too. So hopefully it would be rated for everybody It will be a combined rated round for both divisions. @authors can you please help with this ambiguous statment maybe write it "rated for everybody" ?
 » 13 days ago, # |   0 interesting interactive problem. I hopeeeeeee
•  » » 13 days ago, # ^ |   0 Or another binary search problem for Problemset
•  » » » 13 days ago, # ^ |   0 I like binary search problem <3
•  » » » » 13 days ago, # ^ |   +4 Yeah only when I know it's a binary search problem.
 » 13 days ago, # |   -11 RIP my hairs after 3 hours :(
•  » » 13 days ago, # ^ |   +30 Wait.. You guys still have hair?
•  » » » 12 days ago, # ^ |   0 wait, you guys still have +ve delta
•  » » » » 12 days ago, # ^ |   +14 cuz we guys don't use alts.Lol.
•  » » » » » 12 days ago, # ^ |   0 wait, there are alts??
•  » » » » » » 12 days ago, # ^ |   0 It's clearly not working for you. Lol sorry XD.
•  » » » » » » » 12 days ago, # ^ |   0 Out of my place to conjecture this, but is moongazer your alter ego's account? Seems like instead of discussing ethical issues inside you discussed them here!
•  » » » » » » » » 12 days ago, # ^ |   0 Unfortunately, I am not that insane.
•  » » » » » » » » » 8 days ago, # ^ |   0 well, then tell me what's 1000-7ohh... did you find it intimidatingbut ya i am not your alter ego.
 » 13 days ago, # | ← Rev. 2 →   -12 Eat->Code->Sleep->Repeat
 » 13 days ago, # |   +6 Contest will clash with Roland Garros finals :(
•  » » 13 days ago, # ^ |   +23 The final for me was yesterday with nadal :P
•  » » » 13 days ago, # ^ |   0 Haha true
 » 13 days ago, # |   +37 Everyone here should know that Latoken is a scam exchange: https://www.cointelligence.com/exchanges_list/latoken/ (In Russian): https://telegra.ph/Kak-rossijskij-skam-LATOKEN-zarabatyvaet-dengi-i-stroit-totalitarnuyu-sektu-12-13
•  » » 13 days ago, # ^ |   +9 I mean, it's dealing with crypto, and crypto is highly unregulated...But anyways, free money for CF!
 » 13 days ago, # |   -57 congrats for new macbook tourist
 » 12 days ago, # |   -9 Is this contest rated?
•  » » 12 days ago, # ^ |   +2 Yes, it's rated for everyone.
 » 12 days ago, # |   +7 The scoring distribution is 500 — 1000 — 1250 — 1500 — 2250 — (1750 — 1250) — 3250 — 3500(1750-1250) means?? can anyone explain please.
•  » » 12 days ago, # ^ | ← Rev. 2 →   +5 There will be two parts to the problem. One easier version(F1-1750) and one hard(F2-1250).
 » 12 days ago, # |   -59 One More Macbook to tourist
•  » » 12 days ago, # ^ |   +93 All those downvotes are from Radewoosh alt account.
•  » » » 12 days ago, # ^ |   -12 Wouldn't he get punished(i.e. to clear all vote that was voted by him)for that?
•  » » » » 12 days ago, # ^ |   +3 Bruh
 » 12 days ago, # | ← Rev. 2 →   -42 LOL!
 » 12 days ago, # |   0 so are the ratings of questions according to div 1 or div 2. Hope that this round will not be like the deltix round
 » 12 days ago, # | ← Rev. 2 →   +26 For some reason there is a scoring distribution update in the English version of this blog post, but there is no one in Russian version.UPD: It's ok now.
 » 12 days ago, # |   0 Great
 » 12 days ago, # |   -9 Don't forget to consider the UNUSUAL START TIME
 » 12 days ago, # |   +83 For real, what's the point of making combined round when there are enough problems to split round for both divisions? Nobody from div1 wants to solve first few problems as well as nobody from div2 even reads last few problems
•  » » 12 days ago, # ^ |   +67 for prize distribution purposes :P
•  » » 12 days ago, # ^ |   +73 i want solve first few problems :p
 » 12 days ago, # |   +11 Hope! this round will go better for me than the Deltix round
 » 12 days ago, # |   -21 Downvotes coming in from other Grandmasters on codeforces and radewoosh ! LOL ! Truth is bitter guys !
 » 12 days ago, # | ← Rev. 2 →   +27 The entire comment section in one not-somewhat-related meme:
 » 12 days ago, # |   -6 Most People: This is definitely my chance to prove myself and get MacBook Air!! Tourist: This is definitely my chance to be first again!!
 » 12 days ago, # |   +17 I am betting that tourist will not win this round. It will be some other LGM.
•  » » 12 days ago, # ^ |   +13 You are right :)
 » 12 days ago, # | ← Rev. 2 →   +3 it's div1 + div2 = div3 :)
•  » » 12 days ago, # ^ |   +25 div is not a linear transformation, you can't write div(ax+by)=a*div(x)+b*div(y)
•  » » » 12 days ago, # ^ |   +14 -_-
•  » » » 12 days ago, # ^ |   +19 Divergence(div) is indeed linear...
 » 12 days ago, # |   0 I wonder why there was no official announcement in the blog of unusual timing and even more surprisingly no one in the comments sections pointed that out. I opened my laptop just now to notice this.
 » 12 days ago, # |   0 today junior tesla is expecting to solve 4 problems and upsolve extra 1 problem. Lets see.
•  » » 12 days ago, # ^ |   +1 Depression comes from expectations :(
 » 12 days ago, # |   +16 Thanks to Djokovic I can convince myself that my rating crashed because I was watching Roland Garros finalewhile giving the contest.
 » 12 days ago, # |   -9 Are B pretests weak, or did I solve by mistake? hopefully, it gets FST.:)
 » 12 days ago, # | ← Rev. 5 →   -7 Although the Problem C was very interesting here's a meme
•  » » 12 days ago, # ^ |   +7 ...
•  » » » 12 days ago, # ^ | ← Rev. 2 →   -6 Nah, I helped him sucessfully
 » 12 days ago, # |   +34 Div 1+2 = rating loss
 » 12 days ago, # |   +5 It takes eternity for queue to end
•  » » 12 days ago, # ^ |   +13 Only to get "Idleness limit exceeded on pretest 1".
 » 12 days ago, # |   +12 queueforces
 » 12 days ago, # |   +11 There are no running submissions.
 » 12 days ago, # |   0 Is this still rated because the queue has been stuck for a long time now ?
•  » » 12 days ago, # ^ |   -14 should be as it is same for everyone i think.
•  » » » 12 days ago, # ^ | ← Rev. 2 →   -48 .
•  » » » » 12 days ago, # ^ |   0 It should be rated as queue practically didn't affect the round
 » 12 days ago, # |   +1 I'm waiting for the results of my submissions from last 10 min.
 » 12 days ago, # |   +2 queue too long.
 » 12 days ago, # |   +6 People who are in queue are gonna remain in the queue forever if the number of running submissions is zero.
 » 12 days ago, # |   -44 hope this contest will be unrated
 » 12 days ago, # |   -6 In queue!! ;(
 » 12 days ago, # |   +382 I always wanted to do it, and today I finally did
•  » » 12 days ago, # ^ |   +13 you have plenty of time to play with these queue times :D
 » 12 days ago, # |   -7 If someone wrongly pastes commented solution of A in problem B's submission, and locks problem B alone, won't this be a problem as others in room who have not solved A can see solution of A by solving only problem B ? And what if someone has commented previous problems solutions for all submissions ? How does codeforces handle this ? MikeMirzayanov
•  » » 12 days ago, # ^ |   0 Nice doubt xD (No one can handle this I believe).
•  » » 11 days ago, # ^ |   +3 Do you mean that somebody uploads their solution for A instead of a solution for B by mistake? But a solution for A is very unlikely to pass pretests for B. And it makes no sense to show the source code of failed submissions to hackers (I don't know if that's how it really works, because I have never tried hacking other solutions in non-educational rounds yet).Or do you mean that somebody submits a valid solution for B, together with a commented out solution for A in the same source file? Is anyone ever doing something like this? I do sometimes use my A solution's source code as an initial template for B. But by the time when I'm ready to submit it, no parts of A remain there.
•  » » » 9 days ago, # ^ | ← Rev. 2 →   0 Is there any difference between submitting code with commented solution of other problem in it and pasting it in an open blog ( or social media, IDE, etc. ) ?
 » 12 days ago, # | ← Rev. 3 →   +2 Anyone else having difficulty to understand the Problem C? Or am I the only one?UPD: I got it. And I'm stupid. :(UPD2: I think, I solved it.
•  » » 12 days ago, # ^ |   +5 I perfectly understand it, the only problem is I am stupid and cannot figure out how to solve it ;)
•  » » » 12 days ago, # ^ |   0 Same with me for Problem B. I guess it'll be a sad contest for many.
•  » » » » 12 days ago, # ^ |   0 Unfortunately it was that way for me with both B and C; I suppose I can kiss my pupil rank goodbye...
•  » » » » » 12 days ago, # ^ |   +1 Yes predictor is showing -90 for you
•  » » » » 12 days ago, # ^ |   0 I dunno why but when I first read problem B I was thinking of the 3 columns problem without any proof and then boom dunno how I got accepted L.O.L.
•  » » » » » 12 days ago, # ^ |   0 Would you like to explain what is 3 columns problem?
•  » » » » » » 12 days ago, # ^ |   0 The subproblem I generate to consider problem B i guest?
•  » » » » » » 12 days ago, # ^ |   0 Consider the i, i — 1 and i + 1 position.
•  » » 12 days ago, # ^ | ← Rev. 2 →   +3 I spent half an hour, read several times, and don't understand what it means by "only by swapping numbers in a column". and finally I ask a question to admin, and then I got it.
•  » » » 12 days ago, # ^ |   0 Yes, I didn't notice the announcement first. I felt really dumb noticing it after few minutes.
 » 12 days ago, # |   +20 interactiveforces...
 » 12 days ago, # |   +76 ME: Get's TLE on D :( .No worries, let's stress test by generating some random trees. Google please give me a random tree generator? GOOGLE: Sure
•  » » 12 days ago, # ^ |   +1
 » 12 days ago, # | ← Rev. 2 →   +16 The person who explained B's sample test cases Spoiler
 » 12 days ago, # | ← Rev. 3 →   +8 How to solve E? I think the soln is something like, do individual blocks on k, for last (n % k), if (n % k) is: 1 — then no answer exists any even number — 2 more queries 3 — 3 more queries any odd number more than 3, remove 3 elements in 3 queries and remaining even in 2. Is this roughly along the correct lines?
•  » » 12 days ago, # ^ |   +15 You can think that you have n columns and in one operation you add +1 to exactly k of them. You need to obtain odd sum in each column.
•  » » 12 days ago, # ^ |   +3 How can you go for 11 4? I couldn't get this.
•  » » » 12 days ago, # ^ | ← Rev. 2 →   0 if n % k is odd and k is even, the answer wouldn't exist.
•  » » » » 12 days ago, # ^ |   0 Thanks, then why the hell my solution is failing. Btw this is the only case where answer ceases to exist, right?
•  » » » » » 12 days ago, # ^ |   0 Not sure about when n % k is odd and k is also odd. How are you solving this?
•  » » » » » » 12 days ago, # ^ |   0 Just make a move on first $n - n \% k$ elements and last n % k elements and this is same as k -> odd and n % k -> even.
•  » » » » » » » 12 days ago, # ^ | ← Rev. 2 →   0 you might save some moves by saving up n-(n%k) indices by repeating them in previous queries. liken=13, k=5q1 : 1 2 3 4 13q2 : 5 6 7 8 13q3 : 9 10 11 12 13
•  » » » » » » » » 12 days ago, # ^ |   +3 Yup I know and implemented this too, the above move needs to be done when n/k == 1.
•  » » 12 days ago, # ^ |   0 Answer doesn't exist only when k has more powers of 2 than n I think.
•  » » » 12 days ago, # ^ |   0 n = 6, k = 4:1 2 3 41 2 3 51 2 3 6
•  » » 12 days ago, # ^ | ← Rev. 2 →   +8 That's part of it, but note that it's not always optimal to do $\lfloor n / k\rfloor$ blocks, sometimes you might want to do more or less. When I say more, I mean you can wrap around and cover an index twice. As an example, the optimal strategy for $n = 10, k = 7$ might look like this: ? 1 2 3 4 5 6 7 ? 8 9 10 1 2 3 4 ? 1 2 10 9 8 7 6 ? 3 4 10 9 8 7 6 EDIT: After reading other comments it seems I did E in a very jank way, I did some strange bullshit with blocks of size $k$ that passed pretests so pray no FST.
•  » » 12 days ago, # ^ | ← Rev. 3 →   +32 Make a graph with N + 1 nodes.Node i represents a state where i indices are used odd number of times. Here Node 0 is our starting point, and Node N is our desired end goal. Make an undirected edge from i to j, if you can perform an operation move from state i to state j. (can be bruted).Answer is shortest_path(0, N).Since we can move from one state to another state easily (again, brute), we get the answer after knowing the shortest path.
•  » » » 12 days ago, # ^ | ← Rev. 2 →   0 Edit: Ignore Could you elaborate on how the number of edges can be bruted? Can't the degree of each node be upto O(k)?
•  » » » » 12 days ago, # ^ |   +5 For a state i, brute the number of ones being converted to zeroes. (zeroes_to_ones + ones_to_zeroes = K).This way, you get all neighbours of i in O(k).
•  » » » » » 12 days ago, # ^ |   0 Sorry I just realized my question was utter nonsense. I was asking how this didn't become $O(n ^ 2)$ even though degree could be upto $O(k)$ per node. I forgot $n \leq 500$ in the problem.
•  » » 12 days ago, # ^ |   0 If n%k equals 1 and k is odd, then answer exist. For example, for n = 6, k = 5:1 2 3 4 51 2 3 4 61 2 3 5 61 2 4 5 61 3 4 5 62 3 4 5 6
•  » » 12 days ago, # ^ |   0 Using bfs from the final state and keeping count of number of positions used odd number of times will suffice
 » 12 days ago, # |   +1 Today I got one of the best feeling that is solution D got accepted in last minute.
•  » » 12 days ago, # ^ |   0 I got WA on pretest 3. Can you give some hints?
•  » » » 12 days ago, # ^ |   0 Were your queries more than N/2?
 » 12 days ago, # |   +17 what was pretest 3 of E?
 » 12 days ago, # |   +8 Thanks for including some easy problems for amateurs like me. :)
 » 12 days ago, # |   0 https://codeforces.com/contest/1534/submission/119394653 — This same case passes in my machine in 2 queries, i tried multiple other cases too. But CF says here it took more than 2 queries. Did i miss something here?
 » 12 days ago, # |   +3 D problem... Killed more dreams than Fear every will ... :(
 » 12 days ago, # |   +18 Solved F1 two minutes before the contests ends, what an exciting contest for me.
•  » » 12 days ago, # ^ |   +5 Same here. gg.
 » 12 days ago, # |   0 Can someone tell me, Why I'm getting ILE in Div2D ? SUBMISSION. I mean, I literally tried every combination of printf and endl. But couldn't get it worked. I usually use endl as a flusher but here it's not working.
•  » » 12 days ago, # ^ |   0 vi query(int r) { // cout << "! " << r << '\n'; printf("! %d\n", r); The query format differs from what you print here.
 » 12 days ago, # |   -11 +0 delta GG.Should have not given the contest in the first place :(
•  » » 12 days ago, # ^ |   0 Hey buddy , do you know how can ishow the delta points for some reason i can't see it ?
•  » » » 12 days ago, # ^ |   0 You can either download an extension or use this to see your predicted delta CodeForces Predictor
•  » » » 12 days ago, # ^ |   0 There will be a chrome extension CF predicter refer to this -> BLOG
 » 12 days ago, # |   +6 I feel the problem statements could have been clearer/presented better, especially those with large statements.At first glance, I saw "It can be proven that that if it is possible to recover the XOR sum under the given constraints, it can be done in at most 500 queries. That is, d <= 500", and went to write a code for atmost 500 queries..Didn't help it was an interactive problem, where, if there's a WA I don't know if it's my IO format, or my solution is actually wrong.
 » 12 days ago, # |   0 Was B anything related to finding median of array
•  » » 12 days ago, # ^ | ← Rev. 2 →   0 No, you just find histograms that are higher than both the neighbours and reduce them to until its height is equal to the highest of their neighboursSubmission
•  » » » 12 days ago, # ^ |   0 spend about 1.5 hours thinking ,what might have gone wrong in my median's logic :'(
•  » » » 12 days ago, # ^ |   0 i literally did the same thing but got WA in pretest 2 :( . :(:(:((((((((((((((.
•  » » 12 days ago, # ^ |   0 I solved B by finding every peak in the array (places where the height is greater than before or after), then doing operations to get that peak to the max height of its neighbors.
 » 12 days ago, # |   +8 how to solve D?
•  » » 12 days ago, # ^ | ← Rev. 3 →   +21 Every tree is bipartite graph. You can ask only about nodes in smaller part. To know if node is in smaller part u can use this fact: distance between nodes from different parts is odd. So u just ask about first node, counting (cnt) nodes that have odd distance, and if cnt < (n+1)/2, first node is in bigger part, otherwise it is in smaller part. And then just greedy alg.
•  » » » 12 days ago, # ^ |   0 can u explain these smaller/bigger parts in more detail. And how you are representing a tree as a bipartite graph. Would be appreciated
•  » » » » 12 days ago, # ^ |   +4 So, in bipartite graph every node belongs to one of two parts. Part that contains more nodes than other is bigger part, other part is smaller part. So, as I said if distance between two nodes is odd, nodes belongs to different parts. So, ask about first node, every node that has even distance to the first one, is in the same part with first node, otherwise, if distance is odd, it is in different part
•  » » 12 days ago, # ^ | ← Rev. 2 →   +1 Here was my approach:Arbitrarily choose some node to be the root. Query that node. That gives you the rank of each node in the rooted tree. Our goal is to find the parent of each node.Iterate over the nodes in any order. Query each node whose parent is not yet known. We can use the result of the query along with the rank information to find that node's ancestors, siblings, and children.Notice that if we associate each query with the node and its parent, these pairs don't overlap. This proves that we won't exceed $\lceil\frac{n}{2}\rceil$ queries.
 » 12 days ago, # | ← Rev. 2 →   +5 I think I missed D by printing a edge multiple times :(
 » 12 days ago, # |   0 Did anybody find todays problems had more casework to do or is it just me.
 » 12 days ago, # |   +24 The only time I am in top 500 is during system testing (T_T)
 » 12 days ago, # |   0 How to solve B?I had some proof that decreasing a number to the maximum of two sides will work but got a wrong answer on pretest 2
•  » » 12 days ago, # ^ |   +1 you only need to decrease a number if it is greater than both its adjacent element.
•  » » » 12 days ago, # ^ | ← Rev. 3 →   0 I did so but still a wrong answer. Spoiler#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int tt; cin >> tt; while(tt--){ int n; cin >> n; vector a(n); long long ans = 0LL; for(int i = 0; i < n; i++){ cin >> a[i]; } for(int i = 0; i < n; i++){ int mx = INT_MIN; if(i >= 1){ mx = max(a[i - 1], mx); } if(i < n-1){ mx = max(a[i + 1], mx); } if(a[i] > mx){ ans += a[i] - mx; a[i] = mx; } if(i > 0){ ans += abs(a[i] - a[i - 1]); } if(i == 0){ ans += a[i]; } if(i == n-1){ ans += a[i]; } } cout << ans << '\n'; } return 0; } 
•  » » » » 12 days ago, # ^ |   0 Cut the blocks which are larger than both left and right ones. Spoilervoid solve(){ int n; cin >> n; int A[n+2] = {0}; for (int i=1; i<=n; ++i){ cin >> A[i]; } int ugly = 0; for (int i=1; i <= n+1; ++i){ ugly += abs(A[i] - A[i-1]); } for (int i=1; i <= n; ++i){ ugly -= max(0LL, min(A[i] - A[i-1], A[i] - A[i+1])); } cout << ugly << '\n'; } 
•  » » » » 12 days ago, # ^ | ← Rev. 2 →   0 shouldn't you set mx = 0 at the very start? Cause it's particularly given that we can't go lower than 0 and also it can be proved that there's no benefit of doing that as well.
•  » » » » 12 days ago, # ^ |   +1 I think this is becoz , u have not dealt with n=1 separately for input 1 1 2the answer should be 2
•  » » 12 days ago, # ^ |   0 Erase a block off of a histogram if it is strictly higher than the previous histogram and the one after it. If you do so, you will pay \$1 for each erased block and decrease ugliness by 2.
•  » » 12 days ago, # ^ |   0 Make sure you only do this on bars that are strictly higher than both of its adjacent bars. Also be careful with the left and right end bars as they only have one adjacent bar.
•  » » » 12 days ago, # ^ |   0 I take care of both this situations but it still doesn't work.Can you take a look at my submission if you have time?
•  » » 12 days ago, # ^ |   0 Handle n=1 case separately. For n=1,ans will be arr[0]
•  » » » 12 days ago, # ^ |   0 Yep I see my codes doesn't work there . Thanks!
•  » » 12 days ago, # ^ | ← Rev. 2 →   0 Suppose we have our original array orig and and our new array arr. We want to minimize: $\sum |orig[i] - arr[i]| + \sum_{} |arr[i] - arr[i - 1]|$So.. if we update $orig[i]$ to some $arr[i]$, we need to make sure that it is going to decrease $|arr[i] - arr[i - 1]| + |arr[i + 1] - arr[i]| + |orig[i] - arr[i]|$as compared to $|orig[i] - orig[i - 1]| + |orig[i + 1] - orig[i]|.$And from here, you can formally prove that its optimal to update a value iff it forms a mountain.And this makes some intuitive sense too: obviously, updating a valley is a bad idea. And if we update something that is neither a valley nor a mountain, then its pretty pointless and suboptimal.Also case when $n = 1$ needs some special case (or at least, my implementation needed special care).
•  » » » 12 days ago, # ^ |   +1 Padding the array with one extra 0 element in the beginning and one extra 0 element in the end removes the need to handle special cases.
 » 12 days ago, # |   0 how to solve problem C ?
•  » » 12 days ago, # ^ |   +1 count the number of cycles formed from $a,b$ and then $answer = 2^{#cycles}$
•  » » » 12 days ago, # ^ |   0 I got it, thank you very much
•  » » 12 days ago, # ^ |   +2 2^(number of connected component)
•  » » » 12 days ago, # ^ |   0 I got it, thank you very much
•  » » 12 days ago, # ^ | ← Rev. 2 →   0 Notice that when you swap a pair, you have to swap some more pairs to make the configuration solved. If you swap ai with bi, you have to see where bi is present in a[]. Keep on swapping such pairs until you get ai in b[]. All these pairs form a cycle together which says that if you swap any one of these, you have to swap all of these to keep the configuration solved. There are only 2 states possible for a cycle, straight or upside-down. Count the number of cycles and print 2^cycles.
•  » » » 12 days ago, # ^ |   -8 I got it, thank you very much
•  » » 12 days ago, # ^ |   0 Try to inverse some column, u will notice that now there is same number in first row, then try to inverse it, and repeat it until it has solved configuration. Every column than u have visited belongs to one cycle. Every cycle is independent from other cycles. Every cycle have 2 states. So answer is just 2^(amount of cycles)
•  » » 12 days ago, # ^ |   0 In C, the columns build components. That is, if you swap one column, you also have to swap another one, then another one and so on, until a circle is complete.Find the number of such circles, and ans=2^number since foreach circle we can swap it, or not swap it.
•  » » 12 days ago, # ^ | ← Rev. 2 →   0 Construct a direct graph with edges from $a_i\ ->\ b_i$$answer\ =\ 2^{number\ of\ cycles\ in\ the\ graph}$
•  » » » 12 days ago, # ^ |   -8 I got it, thank you very much
•  » » 12 days ago, # ^ |   0 u have to find the number of connected components. this is because u cannot flip all the columns independently, for instance if some columns are (2,3) (3,4) (4,2) , they all are dependent on each other therefore , if u flip (2,3) u must flip all the pairs of columns that have a common element (here (2,3) (3,4) (4,2) ) So , find total number of connected components (here one of them is 2-3-4) and return 2 raised to the power this number.(as all of them will have 2 ways independently)
•  » » » 12 days ago, # ^ |   -8 I got it, thank you very much
•  » » 12 days ago, # ^ |   0 C gave me deja vu for this problem: 1465C - Peaceful Rooks
•  » » 11 days ago, # ^ |   0
 » 12 days ago, # |   +1 What was pretest 3 in problem D? I failed it 7 times!
 » 12 days ago, # |   0 How to do D? I was trying to start with 1. then I divided all numbers according to their distance from 1. now i would go and choose from nodes at distance i,i+1 and which ever are lesser in number i would iterate over them and print them and find out their neighbours in upper/lower distance level and increment i by 2. this ensures that every time i choose half or less than half elements every time. Hence in total i never print more than n/2+1 elements
 » 12 days ago, # |   0 Why is the code of other people not visible
 » 12 days ago, # |   +1 https://codeforces.com/blog/entry/91617?#comment-803516 YAY I was right. All Tourist fans owe me a buck xD. Congrats Benq
•  » » 12 days ago, # ^ |   0 Still I am a tourist fan
•  » » 12 days ago, # ^ |   +12
 » 12 days ago, # |   0 119382434 Can someone please tell me why I'm getting runtime error on this?
 » 12 days ago, # |   +26 Anyone tried randomization in D and got it accepted?
 » 12 days ago, # |   +8 When Ninjaclasher forces you to do a problem with your own name in it
 » 12 days ago, # |   -6 How to solve B with ternary search?
 » 12 days ago, # |   +57 Thank you for the round! The problems were interesting.
 » 12 days ago, # |   +5 why G was so big constraint? My O(NlogN) solution get TLE (TT)
 » 12 days ago, # |   0 Hey Guys Do you know how can i see the delta points columns in the contest ?
•  » » 12 days ago, # ^ |   +9 install an extension called CF-predictor
•  » » 12 days ago, # ^ |   0 use cf predictor chrome extension
•  » » 12 days ago, # ^ |   0 You can use cf predictor extension. It gives the real time Delta changes during the contest. Just Google it
 » 12 days ago, # | ← Rev. 2 →   +1 Does anyone know why I can't view other people's submissions? Apologies if the reason was mentioned somewhere already and I missed it.
•  » » 12 days ago, # ^ |   0 I was thinking the same. Clicking on solutions, but nothing is happening.
•  » » 12 days ago, # ^ | ← Rev. 2 →   +5 Because admins hasn't made solutions public yet.
•  » » » 12 days ago, # ^ |   0 you can check editorials https://codeforces.com/blog/entry/91760
 » 12 days ago, # |   +3 finally the rating loosing streak is back. So excited to have more negative deltas. Wish me luck.Thanks for this round and making me feel how dumb I am.
 » 12 days ago, # |   -6 It's too sad to see system test get failed, poor pretest hurts more than Wa
 » 12 days ago, # | ← Rev. 3 →   +21 Apparently many people solved $E$ with some casework. You can do also like: (which I think is intended solution). SolutionAt each stage, you count number of numbers which have been XORed odd times and even times. You can let this be a node in a graph. Basically, node $i$ denotes a state in which there are $i$ numbers which have been XORed even times and $n-i$ numbers which have been XORed odd times.Observe that, if you select $j$ out of the $i$ even XORed numbers and $k-j$ out of the $n-i$ odd XORed numbers, then you will now have $i-j+(k-j)$ even XORed numbers. So make edge from $i$ to $i+k-2*j$.Now, just do a BFS from node $n$ and check whether node $0$ is reachable!
 » 12 days ago, # |   +83 Big ups to the authors for the nice problems, and bigger ups for including the answers to the possible sample queries in the interactive problems where it's reasonable. That's such a nice thing to do <3
 » 12 days ago, # |   0 i could't submit D even after solving it cuz even though i saw a sample problem of interactive problem i could not submit it without idleness, please hack my account and put me out of my missery , basically i am under water its too much raining
 » 12 days ago, # |   0 will the number of cycles and number of connected components be equal in C?
•  » » 12 days ago, # ^ | ← Rev. 2 →   0 Yes, basically all connected components will be pure cycles
•  » » » 12 days ago, # ^ |   0 2^(Cycles) is the answer
•  » » » 12 days ago, # ^ |   0 Please can you check my submission 119395523? I calculated 2^(connected comp) but it's giving WA on tc4.
•  » » » » 12 days ago, # ^ |   0 In your solve function, for clearing the g[i], i should be from 0 to n, i.e., for(int i=0;i<=n;i++) (you did i
 » 12 days ago, # |   +6 Is there a way to see how many people failed system test for a particular problem ?
•  » » 12 days ago, # ^ | ← Rev. 2 →   -13 They will never show that as people will backfire for weak pretests. Although this contest had strong pretests. No one on my friend list got FST.
•  » » » 12 days ago, # ^ |   +1 I found a way, just go to the status bar and check all rejected submissions keeping the tests greater than the number of pretests.
 » 12 days ago, # |   +9 What if i tell you, that in problem A you just need to check whether given matrix satisfies: RWRWRW WRWRWR RWRWRW WRWRWR or WRWRWR RWRWRW WRWRWR RWRWRW WRWRWR Realized this in post-contest discussion with my friend.
•  » » 12 days ago, # ^ |   +5 This is the intended solution.
•  » » 12 days ago, # ^ | ← Rev. 2 →   0 I mean, there is no other solutions
•  » » » 12 days ago, # ^ |   0 You can also implement bfs or dfs and color the graph while doing so. Not that it would be better, but it also works.
•  » » » » 12 days ago, # ^ |   0 It would still give chess-like board
•  » » » » » 12 days ago, # ^ |   +5 its just another way of checking it*
•  » » » » 11 days ago, # ^ |   0 this is what i did :)
 » 12 days ago, # |   -6 Finally Tutorials are here. I was thinking of finally offering some goat to the devil. Thanks to problem setters for fast update.PS: BEFORE YOU COMPLAIN NO TUTORIAL TO BE SEEN IN THE BLOG. TRY TO FIND IT FIRST
 » 12 days ago, # |   +8 Fst on D coming :(
•  » » 12 days ago, # ^ |   0 What is FST?
•  » » » 12 days ago, # ^ |   +3 Failed system test
 » 12 days ago, # |   0 Now it's time to wonder if I got a great place thanks to competing drunk or despite competing drunk.
 » 12 days ago, # | ← Rev. 2 →   0 https://codeforces.com/contest/1534/submission/119394653Can somebody try this out on their machine. I submitted this in contest and it gave WA on pretest-1 and i tried it on my machine multiple times and it worked well. I'm really frustrated as I don't understand how the same code in 2 machines can give different output (my strategy isn't random, the program will always query the same nodes for a particular tree everytime it runs).
•  » » 12 days ago, # ^ | ← Rev. 2 →   +5 When your local submissions behave differently from codeforces submissions, it often indicates that your code may have undefined behavior. In your case, I think you are trying to access an element out of bounds of the done array: see 119406377 where the assertions I added fail. I think it is due to the line fire2.pb(mp(x,b+1));, where b can be up to n-1
•  » » » 11 days ago, # ^ |   0 Thankyou so much for taking out the time to look into this and getting back to regarding the issue. I definitely learnt something new today. I understand why this happened now. Have a nice day :)
 » 12 days ago, # |   +28 Thanks for the great problems and strong pretests!
 » 12 days ago, # | ← Rev. 2 →   +13 Looks like highest rating record on codeforces is going to be broken.
 » 12 days ago, # |   +10 Two questions:F: Does anybody remember a similar situation when solving a small version and then trying to upgrade it was a mistake? Normally it's rather a good way, but there the small version required only SCC while the big one doesn't (which may lead you to really long code).H: Isn't an interaction with $10^5$ flushes rather slow/dangerous/generally not CF-friendly?
•  » » 12 days ago, # ^ |   +8 I finally found a problem with a good upgrade in this F. Not like F1 has an interesting idea, just a straightforward "build graph, do SCC", where the main point of failure is building the graph in a wrong way, but there's an element of double checking — if F1 passes, you can expand on it to solve F2, while if your SCC is wrong and pretests for F1 don't catch it, then pretests for F2 might because it's way more than SCC!There's a good reason to go for SCC in F2 even if you don't have F1. As soon as you have it abstracted as a directed graph, compressing to a DAG gives you plenty of guarantees for the next step — actually figuring out the solution. It's not hard to write either, just reproduce those 20 lines of Tarjan from whichever online resource you want.
•  » » » 12 days ago, # ^ |   +10 Well, I took my code to F2, erased the whole thing with SCC, did some obvious stuff and it worked, so I don’t find SCC useful here at all.
•  » » » » 12 days ago, # ^ |   0 Well, I used SCC and didn't have to erase and rewrite, so I think it was a good path to take.
•  » » » » » 12 days ago, # ^ |   0 What’s your solution then?
•  » » » » » » 11 days ago, # ^ |   +18 Mark vertices that you need to cover, make scc, mark respective vertices in scc, unmark those that are reachable from another marked. Now you have set of marked vertices none of which is reachable from the other. I claim that you can sort them in some order that any source in SCC will cover segment of marked vertices, just sort them by column id of any marked representative in scc vertices.Now you have to figure out minimum and maximum reachable marked vertex from each source and cover array with minimum number of segments, which can be done greedily without actually finding segments: take first unmarked vertex, go through back edges and mark every node as visited, from each marked node go down and mark all nodes as visited as well. You will reach all sources that cover first marked vertex, which is precisely what greedy on array does. Then take next marked unvisited vertex and so on.
•  » » » » » » 11 days ago, # ^ |   0 First, rephrase the whole thing as: you've got a directed graph where some vertices are marked (the $a_i$-th sand in $i$-th column), find the smallest set of vertices such that each marked vertex is reachable from at least one chosen vertex.I compress to DAG, note that only topmost components should be chosen, then note that from the way the graph is constructed, no two topmost components can share a column, so they're easy to sort. Also, paths in the graph are actual paths in the grid, so the set of topmost components from which a given vertex/component can be reached is a contiguous interval.With a simple graph traversal, for each component, I find the leftmost and rightmost of the top components which are above it (minimum and maximum of their numbers in sorted order) and the problem reduces to picking the smallest number of points that cover all given intervals, which is well-known.
•  » » 11 days ago, # ^ |   0 I thought there should be a natural extension in F. So I continued with the SCC formulation and reduced it to finding a minimum size set of vertices in a DAG such that every leaf is reachable from some vertex in the chosen set. Then I tried to solve it with some (wrong) flow models. Does anyone know if this problem admits a good solution in general?
 » 12 days ago, # |   0 119382434 Can someone tell me why I'm getting runtime error?
•  » » 12 days ago, # ^ |   0 In practice mode (i.e. after the contest), runtime errors on codeforces can be caught by the C++ diagnostics compiler automatically. I resubmitted and it shows that your char arrays a and c are too small: 119406134
•  » » » 11 days ago, # ^ |   0 Thanks for the information. Is there any way to overcome this error?
•  » » » » 11 days ago, # ^ |   +3 Make the arrays bigger, e.g. char a[n+1][m+1], c[n+1][m+1]. Alternatively, use 0-based indexing in the rest of your code.An array int a[50] only has valid positions a[0], a[1], ..., a[49].
•  » » » » » 11 days ago, # ^ |   0 Thanks a lot
 » 12 days ago, # |   +36 Benq has raised the bar of highest cf rating to 3796 now. Beating Tourist . Congratulations Benq.
 » 12 days ago, # | ← Rev. 3 →   0 https://codeforces.com/contest/1534/submission/119344612 Why did this fst? Can't seem to figure out.Edit -> Don't use global variables when you don't have to.
•  » » 11 days ago, # ^ |   +6 You could simply use "assign" instead of "resize" and you won't have to worry about global variables.Accepted Submission
 » 12 days ago, # |   0 Hi. Can someone explain me why I got WA on test 4 in B? The idea is correct but I can't find the mistake in my solution. Thanks119386786
•  » » 12 days ago, # ^ |   0 hist[i+1] causes an undefined behavior because the max n is 4e5 and the size of hist is 4e5, enlarge hist` by 1 element and soln will pass
•  » » » 12 days ago, # ^ |   0 I gave hist a size of 4 * 100005 which is 4 * (1e5 + 5) so that shouldn't be the problem. Also, I just tried with hist[(int) 4e6] and again got WA on test 4.
•  » » » » 12 days ago, # ^ | ← Rev. 2 →   0 ah, I'm blind, sorry, you don't fill it with zeros for every testcase, that's the reason, it is global
•  » » » » » 12 days ago, # ^ |   0 Thank you, that was the problem, I can't believe that was the reason, well now I will never forget about that lol. Thanks for your help!
 » 12 days ago, # |   0 good to be back
 » 12 days ago, # | ← Rev. 2 →   0 can some one tell why I am getting WA on this submission my friends solved literally the same idea and they got AC I literally can't find any wrong I am getting wrong on pretest 2 my program is printing 01234501234512345623456734567845678956789100 how can the program prints smth like this plz help https://codeforces.com/contest/1534/submission/119401086
•  » » 12 days ago, # ^ |   +8 I made a few little changes in the cases where n = 1 and n = 2, and it passed: 119404096
 » 12 days ago, # |   +19 Since the highest ever rating title was most likely taken (at least for now) from tourist by Benq, do you think he will take his revenge and first reach the 3800 mark?Any bets who will be first over 4000?
•  » » 12 days ago, # ^ |   +5 Neither of them.
•  » » 12 days ago, # ^ |   +12 I suggested this in the past: SpoilerBut now that Benq got the highest max rate on Codeforces history, The competition has become strong!but you forgot Radewoosh, He also get a rating of 3700+now (Benq VS tourist VS Radewoosh), The trio with a rating of 3700+