### zoomswk's blog

By zoomswk, 5 years ago,

Hi, everyone!

Unfortunately, the round was moved two hours later. Sorry for the inconvenience.

It is my honor to announce that the Codeforces Round #408 rated for the second division is going to take place tomorrow at 16:35 UTC. As usual, participants from the first division will be able to participate out of competition.

As the author of this contest, I (zoomswk) would like to thank PoomrokC, nisaruj, and Phoom for testing the problems, KAN and netman for their help in contest preparation, and MikeMirzayanov for the awesome Codeforces and Polygon platforms. Cute graphics in this round are designed by my friend Chonphuech Sripongtanakul, so thanks to her also!

In this round, you will be given 6 problems and 2 hours to solve them. Zane the Wizard, along with his puppy and his crush, will be asking for your help. It is advised that you read all problems and read them carefully.

As per tradition, the scoring distribution will be announced later.

I hope you will enjoy the problems.

Good luck! :D

UPD: The scoring distribution is 500-750-1000-1500-2000-2500.

UPD: The round has ended. Thanks everyone for participating. I'm deeply sorry that the problems turn out to be way harder than I expected. Please stay tuned for the editorial. T_T

UPD: The system testing is complete. Congratulations to the winners!

Div. 2 Winners

Div. 1 Winners

I sincerely apologize that slow input/output methods caused so many TLEs. Unfortunately, it is not possible to rejudge the submissions nor increase the time limit at this point. This is my fault, and I'm terribly sorry. I was not aware of this because my solutions run in < 500 ms of time limit in all problems. I hope you understand.

The editorial will be published in a few minutes, and I'll update this post when it's available.

• +311

 » 5 years ago, # | ← Rev. 2 →   +15 Good luck to you too! I wish your tests to be strong and your problems to be interesting to read, understandable and challenging! :)
•  » » 5 years ago, # ^ |   +14 Thanks! I'm trying my best to make all that happen. ;)
 » 5 years ago, # | ← Rev. 2 →   +55 It's gonna be my first round after breakup :D
•  » » 5 years ago, # ^ |   +16 Meanwhile me "forever-single"
•  » » » 5 years ago, # ^ |   0 which translates to forever-happy!
 » 5 years ago, # |   +23 Zane is The Wizard but still can't make his crush into his girlfriend. I feel it.
•  » » 5 years ago, # ^ |   +52 Don't worry, you'll get to help him in the contest. XD
•  » » » 5 years ago, # ^ | ← Rev. 2 →   -14 Why do i get the feeling that he is going to ask our help to make his crush into girlfriend.
•  » » » » 5 years ago, # ^ |   +12 LOOK AT THIS HANDSOME MAN HOW DARE YOU SUGGEST HE NEEDS YOUR HELP IN GETTING A GIRLFRIEND
 » 5 years ago, # |   +14 I can't register to unofficial participation.
•  » » 5 years ago, # ^ | ← Rev. 2 →   +18 Sorry about that. I've informed the coordinators of this. :)EDIT: Len and abhishek_saini, it has been fixed.
 » 5 years ago, # |   +17 Div 1 Users are not able to register.
 » 5 years ago, # |   +2 How I wish there to be earlier contests since i'm in UTC+8 area.
 » 5 years ago, # |   0 Delaying it 2 hours makes me able to do this round, thank you! :D
 » 5 years ago, # |   +20 Finally zoomswk is writing problems for CF! I heard your problems were really good from some other Triam Udom students in POSN camp 2. Looking forward to participating today!
•  » » 5 years ago, # ^ |   +12 Thanks! Hope you'll like my problems too.
 » 5 years ago, # |   0 Thanks for the delay zoomswk, I would have missed the round. Sorry for them who had suitable time.
 » 5 years ago, # |   0 Pleasant unexpected delay. Now I won't have to sacrifice my dinner this time :)
 » 5 years ago, # |   +1 Too bad, I can't do the round now :(
 » 5 years ago, # |   +50 Rating prediction hereExtensions: Have fun & high rating:)
•  » » 5 years ago, # ^ |   0 I am unable to see the predictions.
•  » » » 5 years ago, # ^ |   +14 When contest start, prediction will work.
•  » » 5 years ago, # ^ |   +5 Thank you as always ! :D
 » 5 years ago, # |   +5 rip UTC+8
•  » » 5 years ago, # ^ |   +5 lets just stay up late tonight
•  » » 5 years ago, # ^ |   +6 lets just stay up late tonight
•  » » 5 years ago, # ^ |   +6 lets just stay up late tonight
•  » » 5 years ago, # ^ |   0 same T_T
 » 5 years ago, # | ← Rev. 3 →   -24 div 2 after long days. ;(
 » 5 years ago, # |   -12 1900 a rating everyone must get a lving![contest:408]
 » 5 years ago, # |   +1 It's not a good time for Chinese now, so sad. :(
 » 5 years ago, # | ← Rev. 3 →   +13 Thank you zoomswk for giving us the opportunity to help someone.
•  » » 5 years ago, # ^ |   0 *opportunity
•  » » » 5 years ago, # ^ |   0 Sorry for my mistake.Now it is updated.
•  » » » 5 years ago, # ^ | ← Rev. 2 →   +70 That's why you don't have friends :D
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   -16 Lol. Correcting something wrong isn't wrong i guess :D
 » 5 years ago, # |   +26 We are not able to help our self with our crush. Lets see if we can help the wizard! XD
 » 5 years ago, # |   -6 good luck
 » 5 years ago, # |   +22 Such an interesting scoring distribution :D
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 It looks like : A-A-B-C-D-E :)
•  » » » 5 years ago, # ^ |   +118 It looks like A-B-D-E-G-H !
 » 5 years ago, # |   0 After a long time, a 750 problem.
 » 5 years ago, # | ← Rev. 2 →   -12 after locking can't see soln of others plz solve this problem as soon as possible
 » 5 years ago, # | ← Rev. 2 →   -12 in problem b , for eg: 4 to 6 swap takes place then is it sure next swap will be from 6 only to somewhere else ?
•  » » 5 years ago, # ^ |   +1 I think "NO" !!
 » 5 years ago, # | ← Rev. 2 →   +96
 » 5 years ago, # |   +27
 » 5 years ago, # |   +40 I can't understand how I managed not to read the only word in bold in the whole statement of C and spending the whole contest solving a different problem...
•  » » 5 years ago, # ^ |   +4 ...You made me realize that i did the same thing lol
•  » » 5 years ago, # ^ |   0 Damn it! I did the same thing.
•  » » 5 years ago, # ^ |   0 Same to me
•  » » 5 years ago, # ^ |   0 same ;-;
•  » » 5 years ago, # ^ |   0 same here, read it only 15 minutes before the end :\
 » 5 years ago, # | ← Rev. 2 →   +24 Look at first and second page of standings :Dremove them pls before rating update ;D
 » 5 years ago, # |   +17 now it looks like 20+ people sit together and code together and submit at the same time :Pwhy this guy so boring?
 » 5 years ago, # | ← Rev. 3 →   +109 These Bots!
•  » » 5 years ago, # ^ |   +3 rating army Lmao
•  » » 5 years ago, # ^ |   +8 And I'm pretty sure code obfuscation is against the rules!
•  » » 5 years ago, # ^ |   +23 Funny that one of these bots was hacked: http://codeforces.com/contest/796/submission/26272062
•  » » » 5 years ago, # ^ |   +1 Thank you i am very proud of hacking a bot, there was an edge case for all the bots probably that would break them
•  » » 5 years ago, # ^ |   0 Hello guy, I wanna know how to show predicted rating changes in standing page like yours, some extensions in browser? Thank you!
•  » » » 5 years ago, # ^ |   +3 Check here.
•  » » » » 5 years ago, # ^ |   0 Thanks a lot!
 » 5 years ago, # |   +80 Codeforces Round #408 (Div. 1,5) :)
 » 5 years ago, # |   -6 is there any better order for F that O(n*sqrt) ?
•  » » 5 years ago, # ^ |   +2 My solution works in O((n + m)logn). Please stay tuned for the editorial.
•  » » » 5 years ago, # ^ |   0 what is test 4?
 » 5 years ago, # | ← Rev. 3 →   +5 Am I right that answer for D is always K - 1 (may be someone even can proof that)?UPD Regarding to comment below that's actually number_of_cities_with_police  - 1.If so, that will explain why we had to print sertificate for an answer.
•  » » 5 years ago, # ^ | ← Rev. 2 →   +5 I guess because the tree is arranged according to the law. So the question is actually how to destroy some roads in order to get number_of_cities_with_police connected components. The best way is to have one police station in every connected component. And because in the tree every city is at most d units away, it is possible to keep this property in partition at the end. I hope you understand :)
 » 5 years ago, # |   +15 Including multiple police stations in the same city in D was evil. Cost me 2 WAs. :(Unbalanced problem set but nice problems! :D
•  » » 5 years ago, # ^ |   0 Now I understand why my solution in D was wrong :(
 » 5 years ago, # |   +1 Can someone please tell How to solve C ???? I spent all time on it ,yet no success :(
 » 5 years ago, # |   +5 WTF is C. C is too difficult
 » 5 years ago, # |   0 Someone tell me how to solve Problem D & E please, I can't wait for the editorial xD
•  » » 5 years ago, # ^ |   +5 In problem D we can run a single bfs from every police station. Then for every city we have its distance to its closest police station as well as the number of different police stations that has its distance equal to the shortest distance. Run a single dfs from vertex 1. For each vertex, let's consider its children. If a children has abs(dis[v]-dis[u])!=1 then we will cut that edge. If dis[v] == dis[u] — 1 then we will count how many vertex like that and we will erase (cnt-1) of them because we only need one of them to maintain the distance. And for (dis[v] == dis[u] + 1), as we already have the number of ways to get to this vertex, we will delete this edge if way[v] > 1 and then way[v]--. That's all!
•  » » 5 years ago, # ^ | ← Rev. 2 →   +12 D is a simultaneously BFS from every city with police. Mark each connected city with nubmer of a source police city, then go through edges and if a "police number" on the left != one on the right, then the edge can be removed. You even don't need the d parameter.
•  » » » 5 years ago, # ^ |   0 I did mostly the same, but only marked cities as "connected" without the number of the source and also marked "used" edges. And if I come upon an unused edge that goes to an already connected city then it can be removed.
 » 5 years ago, # |   +20 The girl's cheating algorithm in E is so complex, almost as if you have experience with it :P
•  » » 5 years ago, # ^ |   0 LOl
 » 5 years ago, # |   0 For problem B, what is the expected output for this input?4 1 3 4 3 4 1 3 3 2
•  » » 5 years ago, # ^ |   0 2
•  » » 5 years ago, # ^ |   0 My program prints 2.
•  » » » 5 years ago, # ^ |   0 Shouldn't it be 3? Confused.When 3 and 4 are swapped, the hole should be underneath cup 3. Again when 1 and 3 are swapped, the bone gets into the hole. Now when 3 and 2 are swapped there should be no change. Did I understand the question incorrectly? :/
•  » » » » 5 years ago, # ^ |   0 Ahh, positions of the cups, got it!
•  » » » » 5 years ago, # ^ |   0 You input n m k then you input the places of the holes.In your test case the hole is in number 4.
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   0 the hole can not be swapped its constant during swaps
•  » » » » 5 years ago, # ^ |   0 The holes don't move when swapping cups.
 » 5 years ago, # |   +1 Can we use greedy to solve the problem D ?
 » 5 years ago, # |   0 when will he post the editorial?
 » 5 years ago, # |   0 Can anyone explain me B? I dont get it completely... more like i thought i knew what was going on there, but i did 9 fails and i dont even know why Was he also changing positions of the holes?
•  » » 5 years ago, # ^ |   0 Holes doesn't change
 » 5 years ago, # |   0 Can someone provide hack case for B?
•  » » 5 years ago, # ^ |   +3 2 1 1 1 1 2
•  » » 5 years ago, # ^ |   +3 i hack using this : 2 1 1 1 1 2
•  » » 5 years ago, # ^ |   +4 2 1 1 1 1 2the answer is 1
•  » » 5 years ago, # ^ |   +12 TL hack with 10^6 numbers. OK if solution hasn't scanf/sync_with_stdio.
•  » » » 5 years ago, # ^ | ← Rev. 4 →   +8 Wow, absolutely forgot about it:(All the contest I couldnt find any other narrow places in B besides the cases aboveI think TL was the main reason for so mane hacks
 » 5 years ago, # |   0 Is problem C just modified BFS starting in the vertex with max guard and max degree, or is there something more? (sorry for my English if it's bad)
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 (wrong solution)
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 No, this is wrong.Take the case:63 3 3 3 3 31 21 31 41 51 6 Answer would be m+1(4) for this.
•  » » » » 5 years ago, # ^ |   0 Indeed, thank you for pointing this out.
•  » » » » 5 years ago, # ^ |   0 What is the approach for C?
•  » » » » » 5 years ago, # ^ | ← Rev. 3 →   +2 Let there be a set of nodes which have equal and maximum weight.For each node 'x' from the set,Final weight of x: Same as original weightFinal weight of neighbors of x: Original weight+1Every other node: Original weight+2 Do this for each x in the set and calculate the minimum maximum weight. EDIT: I got a WA. The reason is that we have to consider every node rather than just the max nodes.(Imagine case where all max nodes are connected to a single smaller node)
•  » » » » » » 5 years ago, # ^ |   0 Shouldn't that get TLE if all of the nodes are with the same value ?
•  » » » » » » » 5 years ago, # ^ |   0 I used multisets so I only had to iterate through first node+neighbours.It took 1s but TLE is still a worry.
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 55 5 4 5 53 13 23 43 5Wouldn't your algorithm give 7 for this case? I think it should be 6.
•  » » » 5 years ago, # ^ |   0 "If t > 3, then the answer is m+2." I think it's incorrect. For example, there can be 10 nodes with maximum value, and one node which connects with each of this nodes.
•  » » 5 years ago, # ^ |   0 I think starting from guard with a max strength and connected to maximum number of other max guards is correct, your algorithm will not work for graph: 10 10 10 10 1 1 1 1 ... 1 2 1 3 1 4 4 5 4 6 4 7 ... Your algorithm starts from 4, and we should start from 1.
 » 5 years ago, # |   +1 -8 in B because i forgot ios::sync_with_stdio(false) D:
 » 5 years ago, # |   +3 it was a big leap from b to C hahaha
 » 5 years ago, # |   +65
•  » » 5 years ago, # ^ | ← Rev. 2 →   +1 Each Id belongs to one person I guess! but if each code are same then they will be skipped without the first one. But he should get punished -_-
 » 5 years ago, # |   0 Hi, Could someone help me out with understanding an optimal solution for D ?Thanks!
•  » » 5 years ago, # ^ | ← Rev. 2 →   +6 I think we can separate the tree in forest, where the root of each tree has a police office in it. This way the answer will always be P - 1
•  » » » 5 years ago, # ^ |   +6 careful with several police stations on same node:)
 » 5 years ago, # |   +3 S**t :( Failed to notice that multiple police can exist in one city :'( maybe that's the reason for getting wa on pretest 6
•  » » 5 years ago, # ^ | ← Rev. 2 →   +3 I don't think it is. I was failing on 6 for the longest time too. What does your solution output for this inout: 5 2 2 1 4 1 2 2 3 4 3 3 5 I believe the correct output is 1 2 (EDIT: Fixed it from 5 2 3 to 5 2 2)
•  » » » 5 years ago, # ^ |   0 1 3 And I believe that's a correct output :(
•  » » » » 5 years ago, # ^ |   0 Sorry, the I actually gave you the wrong input, the first line should be 5 2 2
•  » » » » 5 years ago, # ^ |   0 1 3 isn't correct btw, it should be 1 2
•  » » 5 years ago, # ^ |   0 Damn. I failed to notice that too. My program was based on the assumption that there's only one police in one city ;-;
 » 5 years ago, # | ← Rev. 2 →   +1 I believe that it is the same guy who have the ranks between 3, 30 :D
 » 5 years ago, # |   0 That feeling when you realized problem A minor bug... in the last 30 seconds
 » 5 years ago, # |   +19 The problem set was really very nice. I have enjoyed all the problems. Thanks for the round. Hope to get such good problems from you again.
 » 5 years ago, # |   +53 Submitted D with 9 seconds to spare, let the system tests be kind
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 Let's see.
•  » » 5 years ago, # ^ |   +23 You've got to be kidding me...
 » 5 years ago, # | ← Rev. 2 →   0 I can't forgive myself for wasting too much time to find out why was my B solution failing at test 3 ..
•  » » 5 years ago, # ^ |   0 same here, did u find out? would u like to share with me?
•  » » » 5 years ago, # ^ |   0 I was transferring the bone in u->v , forgot that if glasses u and v are swapped then there are two possibilites u->v or u<-v. Used this, pretests passed.
•  » » » 5 years ago, # ^ |   0 Consider swapping xi and vi. I was only checking if the bone is at Xi so I move it to Vi. I wasn't checking if it is at Vi.
•  » » 5 years ago, # ^ |   0 What was it?
 » 5 years ago, # |   +1 Fake , fake everywhere ..
 » 5 years ago, # |   +2 How to solve E?
 » 5 years ago, # |   +36 Who dis?
•  » » 5 years ago, # ^ |   +8 The reason why system test is pending
 » 5 years ago, # |   0 How to solve B? I have wasted 1 hour and 53 minutes for damn pretest 3 on B...
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 1 ≤ hi ≤ 106, so you can keep them in bool array, like holes[hole] = true.Then check if holes[bone] = true then print bone, break else continue swapping.Link for submission: http://ideone.com/BvFVqI
•  » » » 5 years ago, # ^ |   0 So why didnt it pass?
•  » » » » 5 years ago, # ^ |   0 What if the ball is in v at the beginning?
•  » » » » 5 years ago, # ^ |   0 Because of you didn't check case when v =  = ball
•  » » » » » 5 years ago, # ^ |   +3 omfg im so fckin stupiiiiiiiiiiiiiiiiiiiiid 1:53 of hour lost for that
•  » » » » 5 years ago, # ^ |   0 Ball can be in v too
•  » » 5 years ago, # ^ |   0 I was transferring the bone in u->v , forgot that if glasses u and v are swapped then there are two possibilites u->v or u<-v. Used this, pretests passed. Take care of the current position of the bone.There might be a case in which we are swapping the glasses and neither of them has a bone.If the current pos has hole voila! answer found.Else in the end the final pos is the answer.
•  » » 5 years ago, # ^ |   0 1) if first position contains hole , then obviously print 1 , return 0; 2) else -------> keep track of current position of bone in any variable(say boneVar) -------> Initial value of boneVal = 1(given in question)----- > now iterate for k times and take values of cups to be swapped,,, suppose inputs are cup1 , cup2 for(int i = 0 ; i < k ; i++) for(int i = 0 ; i < k ; i++) { cin >> cup1 >> cup2; if(cup1 == boneVar) boneVar = cup2; else if(cup2 == boneVar) boneVar = cup1; /// now check if the new position of bone contains hole then that is answer if(hole[boneVar]) { cout << boneVar;return 0; } }  if(cup1 == boneVar) boneVar = cup2; else if(cup2 == boneVar) boneVar = cup1;
 » 5 years ago, # |   +6 When system testing will start?
•  » » 5 years ago, # ^ | ← Rev. 2 →   +3 I think it may take a while because as you can see, there are many many spam accounts in today round and moreover, their owners have used "Find and Replace" to replace names of all variables and functions which will make the CF anti-cheat accept their solutions UPD: All bots have been deleted
 » 5 years ago, # |   +12
 » 5 years ago, # |   0 From rank 3 to rank 30 , will those people be removed and ranks will be updated ???
 » 5 years ago, # | ← Rev. 2 →   +2 can we use this to solve E? UPD: It works
•  » » 5 years ago, # ^ |   0 If (p / 2) * k >= n. Obviously, It is the maximal point. Else we use dp with n * p * k states, each state has O(k) transitions.
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 Isn't that O(npk^2) complexity?I came up with a solution with O(n*p*2*k) states and constant number of transitions but didn't manage to implement it during the contest. And it also took my a while to finally accept it afterwards. It turned out to be pretty messy :/. Here is my code if you're interested.UPD: Ok, I missed the point. It's indeed O((n^2)k).
•  » » » » 5 years ago, # ^ |   0 It is the intended complexity too. Again, timelimit is too strict :). 1000 * 1000 * 50 = 5.10^7.
 » 5 years ago, # | ← Rev. 2 →   +18 The cheaters are removed from the rankings, except the one who got hacked on C.
•  » » 5 years ago, # ^ |   0 koil (save the name to remove )
 » 5 years ago, # |   +31
•  » » 5 years ago, # ^ |   +2 Not for all...:( :(
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 It's because C question was Tricky one :) Contest was solely based on A and B questions for most of the people.
 » 5 years ago, # |   0 It wasn't that hard I think.Thanks for you effort :D
 » 5 years ago, # |   +1 Test 66.........
•  » » 5 years ago, # ^ |   0 Did it pass ???
•  » » » 5 years ago, # ^ |   +4 in B many people might receive TLE.
•  » » » » 5 years ago, # ^ |   +3 me too :(
•  » » 5 years ago, # ^ |   +4 Yep, my code TLEd on that test aswell http://codeforces.com/contest/796/submission/26262616Can we have an rejudge since my code is only reading the input in C++?
•  » » » 5 years ago, # ^ |   0 do you ever think about the ones using pascal? how bout their io?
•  » » » » 5 years ago, # ^ |   0 Yeah, i was pretty selfish forgetting about pascal, java, etc
•  » » 5 years ago, # ^ |   0 Why we should get TLE only for cin?? Even in CF ??This should be rejudged :'(
•  » » » 5 years ago, # ^ |   0 I think rejudge won't happen unless there's problems with checkers\validators\tests.
•  » » » » 5 years ago, # ^ |   +10 :'(
 » 5 years ago, # |   +5 Got to hate getting TLE for using cin instead of scanf
 » 5 years ago, # |   +1 I think there were some problems with the server during system testing. At B, many people(as have I), have got a TLE even if the complexity was linear in the numbers read.
 » 5 years ago, # |   0 i am rotting at the newbie section
 » 5 years ago, # | ← Rev. 2 →   +6 TLE on B? What is this dude?
•  » » 5 years ago, # ^ |   0 slow io
•  » » » 5 years ago, # ^ |   0 In CodeForces we shouldn't get TLE for this -_- :\Since our algorithm was right; we should get AC!
 » 5 years ago, # |   +4 TLE on problem B because I forgot to use fast IO 26261895
 » 5 years ago, # |   0 Problem C TL is so tight... my solution passed pretests with 1500 something ms and so did many others. Now my solution got TLE (probably ran a test in about 2100 or so ms) while many others are getting AC with 1950+ms solutions.Not fair in my opinion.
 » 5 years ago, # |   0 Could , someone please tell me the reason of TLE in this code of div 2 , B? 26277647
 » 5 years ago, # |   0 Could someone Please tell me why am I getting tle in Java in div2b problem. My code's complexity is O(K) . Here is my submission. please check Here..
•  » » 5 years ago, # ^ |   0 Big input.... Feel ya
 » 5 years ago, # |   0 Time limit for problem C is too strict. Solution use multiset must pass.
•  » » 5 years ago, # ^ | ← Rev. 3 →   +8 I know right? I used multiset and got TLE... if TL was 3000 it would have passed. I'm pretty sure they are not gonna rejudge though, unfortunately :/
•  » » » 5 years ago, # ^ |   +2 I used a multiset and passed. http://codeforces.com/contest/796/submission/26267399
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 I use multiset (C++) and it passed:)After this comment I've checked time of my solution ... it is 1949!
•  » » » 5 years ago, # ^ |   0 http://codeforces.com/contest/796/submission/26276914Used multiset and TLEd......... they should rejudge it with a higher TL imo. If you go ahead and check everyone's solution there's A LOT of them that passed with 1900 or more ms.I agree that sometimes you may be lucky and get AC with a high time. However in this case half of the AC solutions (or even more) had 1900+ ms.
•  » » » » 5 years ago, # ^ |   +1 Here is my code: http://codeforces.com/contest/796/submission/26271475. Looks like you perform twice as much inserts/erases. That may be the reason why you've got TLE.
•  » » 5 years ago, # ^ |   0 My solution with Segment tree passed in 1123 ms.
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 My solution using multiset passed with 1.85
•  » » 5 years ago, # ^ |   0 Strange... I got AC with 1231 ms http://codeforces.com/contest/796/submission/26271625
•  » » » 5 years ago, # ^ |   0 you use C++14, this may be clue:)
 » 5 years ago, # |   +2 I got good on problems A, B and D, but after tests i only got A... Failed on TL on B and wrong answer on test 13 on D. http://codeforces.com/contest/796/submission/26274912
 » 5 years ago, # |   0
•  » » 5 years ago, # ^ |   0 for cin, cout use these two lines in front of main: ios_base::sync_with_stdio(false); cin.tie(0);
•  » » » 5 years ago, # ^ |   0 The core of the task consist in using these "two lines in front of main: ios_base::sync_with_stdio(false); cin.tie(0);" with cin,cout?
•  » » » » 5 years ago, # ^ |   0 Or you can use old, fast scanf and printf :/ I also got TLE on that problem :/
•  » » » » » 5 years ago, # ^ |   0 Why did your do it?
•  » » » » » » 5 years ago, # ^ |   0 I used cin with sync...
•  » » 5 years ago, # ^ |   0 don't use cin , use scanf
 » 5 years ago, # |   +13 Why is the system testing so slow? It seems like it is hung...
 » 5 years ago, # | ← Rev. 2 →   0 WA on Test 61 on problem B!!! why ??? :( :( 26270333
•  » » 5 years ago, # ^ |   0 cin vs scanf war.
•  » » » 5 years ago, # ^ |   0 How Does scanf and cin make Difference to the input except TLE ?
•  » » » » 5 years ago, # ^ |   0 Sorry my bad. I thought about TLE . :(
 » 5 years ago, # |   +1 Failed Test 64 :-( http://codeforces.com/contest/796/submission/26274847Why?
•  » » 5 years ago, # ^ |   0 I failed on 64 too!http://codeforces.com/contest/796/submission/26275877
 » 5 years ago, # |   0 why system testing does not finishes?
•  » » 5 years ago, # ^ |   +8 Am I only one who couldn't access codeforces for about 5-7 minutes?
 » 5 years ago, # | ← Rev. 3 →   +1 I really hoped the purpose of Question B was more than just rejecting cin and accepting scanf -- it probably shouldn't have been a CF problem if that was really the case.
•  » » 5 years ago, # ^ |   -18 BAN zoomswk
•  » » 5 years ago, # ^ |   0 Really this problem shouldn't be in CF. Today I will become a pupil :'( :'(
•  » » » 5 years ago, # ^ |   +6 Welcome to our school!
•  » » 5 years ago, # ^ |   0 I've solved with cin/cout (1185 ms)
•  » » » 5 years ago, # ^ |   0 You have ios_base::sync_with_stdio(0); cin.tie(0); In your code!..But this shouldn't be a problem in CF. Right Algo should get AC :'(
•  » » » » 5 years ago, # ^ |   +9 this is very common trick and it known by everyone who use cin/cout :)
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 What I really meant was that I didn't expect the entire purpose of the question to be testing fast I/O...
 » 5 years ago, # |   0 In fact some codeforces round ends up in first 40-50 minutes.
 » 5 years ago, # |   +6 Slowest System Testing Ever.
 » 5 years ago, # | ← Rev. 4 →   0 Too long testing today. Eyes are on the screen for a long time, now tired :(
 » 5 years ago, # |   +1 B and C are all about file reading optimizations. Had to switch pypy to cpython for it.
•  » » 5 years ago, # ^ |   0 How to solve C?
 » 5 years ago, # |   +7 It's time to eat breakfast.
 » 5 years ago, # |   +3 They should mention about the faster I/O method in the question
 » 5 years ago, # | ← Rev. 2 →   +24 Is it just me or recently in div 2 rounds the difficulty gap between problems is getting larger?
 » 5 years ago, # |   0 They removed bots !
 » 5 years ago, # |   0 Seems like they made case #66 of B only for removing solutions with cin/cout >_<
•  » » 5 years ago, # ^ |   0 They should have made that test #1 for faster testing :D
•  » » » 5 years ago, # ^ |   0 The entire purpose of that problem was to test fast i/o ? >_<
•  » » 5 years ago, # ^ |   0 I used cin/cout in B and got AC!
•  » » » 5 years ago, # ^ |   0 How? I used too and go TLE, with scanf it passes tests
•  » » » » 5 years ago, # ^ |   0 Use this in main() to avoid TLE due to I/O! std::ios::sync_with_stdio(false); cin.tie(0); `
 » 5 years ago, # |   0 in C, my O(n) solution with printf/scanf got TLE :|
•  » » 5 years ago, # ^ |   0 I managed to think nlogn. How to solve in O(n)?
•  » » » 5 years ago, # ^ |   0 One possible O(n) approach is realizing that we always start with the node that is neighbouring to the most nodes with maximum value. If the node itself has maximum value it is also counted as neighbouring itself. In the case of a tie choose a node that is maximal itself. Then hack from there.This works in O(n) and can be implemented quite cleanly: submission
 » 5 years ago, # |   0 Problem B: How is this submission displaying an additional "1" at the end? It's driving me crazy.The output on my IDE doesn't include the additional "1" at the end.
•  » » 5 years ago, # ^ |   0 You shall end program here if (holes[1] == 1) { cout << "1" << endl; break; // return 0; }
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 Still, the 'break' instruction will exit the 'while' loop to the "return 0" line. EDIT: removing the entire if(holes[1]==1) part from the code and running it on codeforces will still display "1" at the end.
•  » » » » 5 years ago, # ^ |   0 Use this: std::ios::sync_with_stdio(false); cin.tie(0);And u will pass tests
•  » » » » 5 years ago, # ^ |   0 The other 'break', when the ball is dropped into a hole, won't exit the 'while' loop though, since it is located inside a 'for' loop.
•  » » » » 5 years ago, # ^ |   0 Well, haven't noticed while at first... But problem still is pretty the same. When you get ans = 55, there is still some data in input stream and while works until the data is gone or hole[1] == 1 case worked
 » 5 years ago, # |   0 Can someone explain to me why I got Runtime Error on test 111 of problem C (div2)?http://codeforces.com/contest/796/submission/26283235
 » 5 years ago, # |   0 Yeap... Thought about using scanf(), but was too lazy...
 » 5 years ago, # |   0 I tried dfs on the problem D,and got a wrong answer on 6.26286839 I saw the others used bfs.So dfs is a wrong way?Can someone help me ?
 » 5 years ago, # |   0 Got runtime error test 38 Problem A http://codeforces.com/contest/796/submission/26263998Later tried test 38 in Codeblocks, works normally and correctWHY?
•  » » 5 years ago, # ^ | ← Rev. 2 →   +1 I recommend you to check whether the index is in the bounds before accessing the array elements.http://codeforces.com/contest/796/submission/26289242
 » 5 years ago, # |   0 Where can you see the standings (scoreboard) for the Div 1 users?
 » 5 years ago, # |   0 DIV2-C: Got TLE in testcase 35. can anyone help me in analysing the time complexity of this submission Thank you in advance :)
 » 5 years ago, # |   0 Hello everyone, could somebody tell me why I got AC instead of Time limit after I use scanf instead of cin for solving the problem B — Find The Bone. I'm so confused now, thanks a lot!!
•  » » 5 years ago, # ^ |   0 Sorry, I got my answer above, thanks.
 » 5 years ago, # |   0 I got a WA on test 6, whose input is: 5 1000000000 0 1000000000 0 1000000000 1 2 2 3 3 4 4 5 and the answer is 1000000002 ; but I think the right answer is 1000000001(with hack order 3 1 5 2 4)....I need help...I can't understand why..TAT
•  » » 5 years ago, # ^ |   0 Read the three conditions carefully. After the bank 3 is hacked, you can only choose to hack banks 2 and 4. Banks 1 and 5 cannot be hacked yet because they are not neighboring to any offline banks.
 » 5 years ago, # |   0 I just wonder if the algorithm still work when the city is not a tree in problem D.
•  » » 5 years ago, # ^ |   0 It will still work. The solution would be more obvious could the input be any graph, wouldn't it? XD
•  » » » 5 years ago, # ^ |   0 Got that! Thank you :) Now I see the reason that you make the country a tree haha...
 » 4 years ago, # |   0 Is problem C in this contest updated ?
•  » » 4 years ago, # ^ |   0 I haven't done anything with it. What's the matter? :O
•  » » » 4 years ago, # ^ |   0 I am so sorry .The wrong with me i thought this is another problem :D.Thank u for caring.