### Warawreh's blog

By Warawreh, 9 months ago, ,

Hi, Everyone!

At Jan/20/2019 15:05 (Moscow time) will start Codeforces Round #533 (Div. 2). Round will be rated for second division (rating below 2100). As usual, participants from the first division can participate in the contest out of competition.

The round will consist of 5 problems in which you will be helping some of my friends and you will be given two hours to help them.

I would like to thank MikeMirzayanov for the Codeforces and Polygon platforms, _kun_ for round coordination and help with preparation. Also thanks to V--gLaSsH0ldEr593--V, Aleks5d,Nebuchadnezzar, Arpa, mohammedehab2002 and osaaateiasavtnl. for help with preparation and testing round.

As usual score distribution will be announced shortly before the contest.

Good luck!

UPD1: I'll be on the Discord channel after the contest, so we will be able to discuss the problems.

UPD2: Score distribution : 500-1000-1500-2000-2500

• +356

 » 9 months ago, # | ← Rev. 2 →   +4 which you will be helping 5 of my friendsWhat does this mean?And also... thank you for the contest!Also... why is the time so early?
•  » » 9 months ago, # ^ |   +42 In each problem you will be asked to help one of my friends by solving the problem So it does not clash with codechef cookoff
•  » » » 9 months ago, # ^ |   +3 Oh okay, thanks! Then on Sunday I guess it's cuz I'll be taking USACO contest too. :)
 » 9 months ago, # |   0 I knew it!!! The date of the contest would shift as there can't be 11 days gap b/w 2 Codeforces contests.
•  » » 9 months ago, # ^ |   0 I see your comments in contest discussions, but the last contest you participated was back in Aug 2018.Are you one of those guys who are worried about rating drops and watch contests like a football game? :thinking:
•  » » » 9 months ago, # ^ | ← Rev. 3 →   +1 Why are you so angry, bro? I will give the contest once I get hold of the topic I have been practicing!!!
 » 9 months ago, # |   +33 best time for the contest... i will not miss my dinner
 » 9 months ago, # |   -13 its much better than 18:05 thank.
 » 9 months ago, # |   +7 I believe that it would be a nice round Warawreh ;)
•  » » 9 months ago, # ^ |   -26 i beliebe that it won't ;)
•  » » » 9 months ago, # ^ |   0 Lets see !
 » 9 months ago, # |   0 During this time my neighbours are very loud :(
 » 9 months ago, # |   -13 Oh at 2 pm I will still be in church, maybe next time then, goodluck with your contest though hope it will be a success and codeforces like its problems.
•  » » 9 months ago, # ^ |   -26 church haha
 » 9 months ago, # |   +44 I am expecting a really great round ! warawreh ♥
•  » » 9 months ago, # ^ |   -24 im not! warawreh ♥
 » 9 months ago, # |   0 I love the original rounds like this one more than any other modified rounds! :D
 » 9 months ago, # |   0 jordanian problem setters ، so excited to this contest
 » 9 months ago, # |   -8 good luck everyone ... including me :D
 » 9 months ago, # | ← Rev. 3 →   -41 bad timing
•  » » 9 months ago, # ^ |   0 I don't understand, why do you think a fine Sunday evening (for Indians) is a bad timing? :thinking:
•  » » » 9 months ago, # ^ | ← Rev. 2 →   -14 Because maximum times contest is organized at night and that is the best time to give contest because you are relaxed from all the works. So comparatively it's bad time. That's it.
 » 9 months ago, # |   0 I think,it is your first round in CF Warawreh.Hope no ambiguity in problem description.Good luck.
 » 9 months ago, # |   -41
•  » » 9 months ago, # ^ |   -17 Level 100 Boss
 » 9 months ago, # |   +19 Damn, I know that Americans are a minority on codeforces, but many of the recent contests have been at bad times (6 AM) for us in California, and this one is 4 AM as well. :'( Of course it doesn't make sense to base the timing off of americans, but I hope there will be one at a reasonable time for us soon!
•  » » 9 months ago, # ^ |   +12 What? The 6 AM round is the best kind of round, because you can just wake up and play right away. No more anxious waiting. One and done.
•  » » » 9 months ago, # ^ |   +3 Haha yeah, that's true. When I can wake up that early, 6 AM is good. But I like sleeping in too much to wake up that early these days.
•  » » » » 9 months ago, # ^ | ← Rev. 4 →   +9 In our country, many (recent) competitions start at 23:35(UTC+9). Most of the contests end at 01:35 or 02:05. I cannot sleep until then and sometimes I sleep later (at around 3 to 4 A.M.) in competitions where they have open hacking. Isn't it better for the competition to start at 6 a.m.?
•  » » » » » 9 months ago, # ^ |   +8 Your 6 is someone's 2.
•  » » » » » » 9 months ago, # ^ | ← Rev. 3 →   0 I think your reply should be posted in a different comment.
•  » » » » » 9 months ago, # ^ |   +3 Yeah, of course any time is good for some people and bad for some other people. I've just noticed that all the competitions recently are at this same time. I think I would just like to see some competitions at different times.
 » 9 months ago, # |   -9 last minute information: codeforces admins are communists
 » 9 months ago, # |   +2 Thanks god it's sunday otherwise i will be in college till 5:30pm (IST)
 » 9 months ago, # | ← Rev. 2 →   0 I think it will be a great round.
 » 9 months ago, # |   0 I believe that it would be a nice round Warawreh ;)
•  » » 9 months ago, # ^ |   0 i believe that it won't ;)
 » 9 months ago, # |   +5 Jordanians problem setter, but it clashes with Jordan vs Vietnam match.Sorry Jordan, we don't have a jordanian codeforces round set up by my friend every day XD.
 » 9 months ago, # |   +19 Please just order problems correctly by their difficulty, because lately many round setters didn't :D
•  » » 9 months ago, # ^ |   +4 One of these rounds you are talking about D/E had the same score so do try to check the score instead of letters before saying that https://codeforces.com/contest/1100/standings
•  » » » 9 months ago, # ^ |   0 That contest may have failed to control the difficulty level because the problem setter set problem for the first time. (But it was a bit harsh. The difference in the rating between problem C and problem D was 1100.)
•  » » » 9 months ago, # ^ |   +23 That's not one of the contests I have in mind. I will give you 2 examples I was referring to: Educational Codeforces Round 58 Where Problem E was far easier than both problems C and D. Yes I know this is an educational round and it's based on ICPC rules, but still that's not a good thing given that it's traditional for problem E to be harder than both C and D. Hello 2019 problem F is easier than problem E.
•  » » » » 9 months ago, # ^ |   +16 Fair enough. For Hello 2019 it's a bit less clear since a huge part of the problem was that the O(N * sqrt(N) * log(N)) intended solution works fast enough. That educational E was really a joke tho...
 » 9 months ago, # |   0 I would participate on this contest but for Sorry I have a final exam the day after tomorrow I'm so sad god damn exams
 » 9 months ago, # |   +1 The first time I see Codeforces Round at 7h00 pm in Vietnam. However, Vietnam National Football team is going to have a match at 6h00 pm. "Viet Nam Vo Dich"
 » 9 months ago, # |   +3 Clashing with Atcoder contest
 » 9 months ago, # |   +30 Some guys said ustat is dead,Tell them, the ustat is back.
 » 9 months ago, # |   +33 I think the author made a mistake in the title. It should be "Codeforces Round #533 (Div. 3)".
 » 9 months ago, # |   +6 How to solve C ?
•  » » 9 months ago, # ^ | ← Rev. 3 →   0 dp[n][3]dp[i][j] is the number of ways to make an i digit number, having remainder j
•  » » » 9 months ago, # ^ |   0 Can you explain it little detailed ?
•  » » » » 9 months ago, # ^ |   +1 suppose you have an i digit number that sum of its digit modulo 3 is j then if you write digit x in the end of that,then you have an i + 1 digit number that has sum (x + j) % 3 so you can say : dp[i + 1][(j + x) % 3] += dp[i][j]you can calculate this dp in O(n) because x have only 3 general states,and at the end, the answer is dp[n][0]sorry for my poor english
•  » » » » » 9 months ago, # ^ |   0 tnx a lot :D
 » 9 months ago, # |   +9 This comment was helpful for problem E :)
 » 9 months ago, # |   0 E:Helping HiasatNo, I don't want to help him, he is so hypocritical.
 » 9 months ago, # |   +6 4th test for E?
•  » » 9 months ago, # ^ | ← Rev. 3 →   0 It fails when you no of connected components.Maybe -12 412 a12 b12 c12 a2 c12 b2 c
 » 9 months ago, # |   +2 Я правильно понял, что E это втупую поиск максимальной клики?
 » 9 months ago, # |   +14 15th test on D?
•  » » 9 months ago, # ^ |   0 I think it had something to do with needing to do a multi source BFS instead of a single source BFS.
 » 9 months ago, # |   +6 Can someone tell me why I am getting TLE on pretest 6 on C? Submission
•  » » 9 months ago, # ^ |   0 Slow input caused by cin
•  » » » 9 months ago, # ^ | ← Rev. 2 →   +3 Nope, I submitted 6 times, with cin optimizations, without them, with scanf, etc. All TLE. Besides, it's only 3 numbers.
•  » » » » 9 months ago, # ^ |   0 True, had problem D in my mind with that large input. Didn't remember C only had 3 numbers, my bad.
•  » » » » » 9 months ago, # ^ |   0 But cin is ok for problem D.
•  » » » » » » 9 months ago, # ^ |   0 If you don't use the sync_with_stdio line I don't think it is
•  » » » » » » » 9 months ago, # ^ |   0 I think so,but why not use it
•  » » » » » » » » 9 months ago, # ^ |   0 The solution he had linked had that line commented, hence it would have TLEd for a large input problem. That's where I mixed things up and thought problem C had a large input and that was the reason for the TL.
•  » » 9 months ago, # ^ | ← Rev. 2 →   0 2 1 1 try this one
•  » » » 9 months ago, # ^ |   +13 Excuse me while I go kill myself.
•  » » 9 months ago, # ^ |   +1 i've got TL 6 with same bug. while(r % 3 != mod) r--; in c++ negative number % x is negative.
 » 9 months ago, # |   +9 Nice problemset!
 » 9 months ago, # |   +5 Is E something like building a graph of friends that can't both be picked (i.e. there's an edge between two friends if they both cant be satisfied) and then doing meet in the middle on that to try and find the best valid subset of friends?
•  » » 9 months ago, # ^ | ← Rev. 2 →   +10 Use meet in the middle to speedup the naive algorithm for finding maximum independent set.
 » 9 months ago, # | ← Rev. 2 →   0 Do anyone passing the pretest for problem E using randomized algorithm for Maximum Independent Set (MIS)?**Update: System test Accepted ;)
•  » » 9 months ago, # ^ |   +13 You must have some balls of steels to submit it in a rated contest. If this isn't rated for me I would have tried to use this opportunity to test my simplex template.
•  » » » 9 months ago, # ^ |   0 Well, I'm just trying whatever I know because I don't know any other algorithm to solve MIS problem :(
•  » » 9 months ago, # ^ |   0 Bruteforce was too slow, but I was lucky to find the correct solution before. Just a timer to exit the search early if necessary. 48631423
•  » » 9 months ago, # ^ |   -8 Yes, my randomized brute passed, but it was not at all the intended soution.
 » 9 months ago, # |   0 48635541 I actually got stuck during the contest, why did my submission of problem C get time limit exceeded ?
•  » » 9 months ago, # ^ |   0 Try 1 1 1
•  » » » 9 months ago, # ^ |   0 Thank you so much, I wonder how stupid I was
 » 9 months ago, # |   -7 Was D just an implementation problem or there was some observation to do for speed-up? I implemented (naive) multi-source BFS but still getting TLE
•  » » 9 months ago, # ^ |   +7 BFS is good enough.
•  » » 9 months ago, # ^ |   +2 I tried to calculate the distances of every free cell to each player (using the speed information) and calculate for each cell, the first player to reach them. But i got WA because there are some cases where a player can block other and reach a cell first even having to play more rounds. So i thought the right solution was the naive BFS and didn't have time to implement it. Now i'm curious too =)
•  » » 9 months ago, # ^ |   +1 BFS with early break out should be good enough, because each cell will be pushed to the queue no more than once, and will be visited extra no more than 4 times (you can "bump" into each square once from each direction).
•  » » » 9 months ago, # ^ |   0 yep, that's exactly what I thought. How do you deal with 'speed of expansion'? I implemented a lower-level BFS that will expand until distance_from_local_source < player_speed, probably that got me a TLE
•  » » » » 9 months ago, # ^ | ← Rev. 3 →   0 Try this testcase3 3 3...###123
•  » » » » » 9 months ago, # ^ |   0 BFS stops at first iteration for every player because the queue doesn't get any new element pushed? Was that your point?
•  » » » » » » 9 months ago, # ^ |   0 Yes I got a tle because of this.
 » 9 months ago, # |   +8 The contest reminds me of how much do I hate hacking in div2 contests -- A problem is either trivial and submitted by a lot of people, making it boring to go through all of them, or there are very few people who submitted it...Yes, I am salty about losing 5 hacks to another roommate who only started hacking 30 minutes before I started. ;_;
 » 9 months ago, # |   0 Shouldn't this solution give Runtime error? on 1 1 a https://codeforces.com/contest/1105/submission/48622609
•  » » 9 months ago, # ^ |   +3 a[i+1] for i = 0 will give garbage value, it'll work without RE
•  » » » 9 months ago, # ^ |   0 It gave WA eventually :(
 » 9 months ago, # | ← Rev. 3 →   -15 Probably the worst round in Codeforces history, imbalanced and not interesting problems, didn't expect it from such a noname.
•  » » 9 months ago, # ^ |   +4 ShutUp..!! It was good.
•  » » » 9 months ago, # ^ | ← Rev. 2 →   +5 I bet you think so just because you didn't try to solve anything except ABC
•  » » » » 9 months ago, # ^ | ← Rev. 2 →   -24 ...
•  » » » » » 9 months ago, # ^ |   +5 How is your phrase related to my comment?
•  » » » » » » 9 months ago, # ^ | ← Rev. 2 →   -27 ..
•  » » » » » » » 9 months ago, # ^ |   0 I don't understand what you want to say. I didn't state anywhere that I'm good at something. It was said, that this round is bad, and your performance depends only on your hands
•  » » » 9 months ago, # ^ |   -14 Only because you did well
•  » » 9 months ago, # ^ |   +12 I don't think so.
•  » » » 9 months ago, # ^ |   +5 D is prue implementation, and E is a classic algorithm just using Meet-In-The-Middle. Jf course, if your level is at ABC, you won't feel that anything's wrong with DE and so on, but that doesn't make these tasks good and worthy for Codeforces
•  » » » » 9 months ago, # ^ |   +1 That's true to some extent, but there were even worse competitions.
•  » » » » » 9 months ago, # ^ |   +1 Okay, I agree, maybe it's not the worth, but one of them obviously
 » 9 months ago, # |   +17 Is E just finding size of maximal independent set with meet-in-the-middle? If so why do you do things like this?(((
 » 9 months ago, # | ← Rev. 2 →   -17 warawreh's hit contest
 » 9 months ago, # | ← Rev. 3 →   0 Someone please help me, For problem AI tried a hack on the solution.This solution initializes s[n+1] but uses s[t] somewhere between the code.For a test case like: 2 88 100 s[] should overflow because, t can take values from 88 to 100, but s[] is initialized only for 0 to 1.But my hack failed. Why is his solution still printing the right answer?UPD: He failed main tests :/ . Still it was my first ever hack and learnt about how overflow actually works :)
•  » » 9 months ago, # ^ |   0 I suppose that only s[3] and s[4] is corrupted due to overflow, you need a testcase to trick the code into reading these two slots.
•  » » » 9 months ago, # ^ |   0 Oh so is that how overflow works?I thought any number greater than the limit would have created overflow...Can u explain me in detail?
•  » » » » 9 months ago, # ^ | ← Rev. 2 →   +11 This is what my Operation System course taught me:So, when the C++ code writes "s[n+1]", the OS allocates some memory to the code, and the same thing happened when it asked for memory for p and j. The OS make use of the stack and use the 2 records right after s[n+1], which, pointer arithemetic tells you that it is equivalent to s[3] and s[4] (Or around s[3], I am not entirely sure about this tbh. Perhaps since s[3] is allocated to the array to store '\0' so it is actually s[4] and s[5]).Then, when s[88] is called, it look into *(s+88), which is not occupied by anyone. Luckily, this is also not out of the memory bounds that the OS allocated to the process, so calling s[88] will neither access corrupted memory nor trigger segmentation fault.
•  » » » » » 9 months ago, # ^ |   0 Thank you for the explanation. It was my first hack (though it failed), I learnt something new :)
 » 9 months ago, # |   +5 Any clue to get past pretest 5 on D?
 » 9 months ago, # |   +37 People like thinking during a contest, do not take away this opportunity from them
•  » » 9 months ago, # ^ |   +1 At least you can quit in the middle of a contest ;_;
•  » » » 9 months ago, # ^ |   +1 Gentlemen don't do that
 » 9 months ago, # |   0 Problem C is so cool for me. Thanks for this contest, its very nice! :D
 » 9 months ago, # |   -10 I have to say that problem D is really really really inappropriate to be D. May be C and D could have been swapped.
•  » » 9 months ago, # ^ |   0 BTW pretests are too weak, my friend failed both B and D. Hope that will never happen again next time.
 » 9 months ago, # |   +3 Hmm... this is weird...but anyone have any ideas of pretest 15 of D?
•  » » 9 months ago, # ^ | ← Rev. 3 →   0 try this case 4 3 2 2 1 1.. 1.. ..2 ...
•  » » » 9 months ago, # ^ |   0 Figured. Thanks.
 » 9 months ago, # |   0 "have a castle their"
 » 9 months ago, # |   -11 Also, this maybe a bit too much, but I'd be glad if the part one or more castles in statement of problem D is written in bold or italic to emphasize it.I wasted 3 failed submissions and half an hour by misreading this part, thinking each player will only start with one castle. It's not that I want to blame, but such crucial information should be emphasized.
 » 9 months ago, # |   0 Why are there so many Failed System Test in problem A?
•  » » 9 months ago, # ^ |   0 Some people only checked for t = values of the given array for some reason.
•  » » » 9 months ago, # ^ |   0 ... Okay, but I think other reasons also exist.
•  » » 9 months ago, # ^ |   0 many sort the array pick the middle and calculate the ans.
•  » » » 9 months ago, # ^ |   0 Thank you.
•  » » 9 months ago, # ^ |   0 Many players assign x to the median of array a
 » 9 months ago, # |   +6 I suggest that the key words should be BOLD in the statement.
 » 9 months ago, # |   0 I got accepted on problem B with DP solutionSeems too overkill
 » 9 months ago, # |   +48 Div. 2.5
 » 9 months ago, # |   -10 Congrats Warawreh.Impresive Debut as a problem setter in CF.
 » 9 months ago, # | ← Rev. 4 →   0 Does 1.0 * clock() / CLOCKS_PER_SEC actually give the time the program took to run? For question B, I was getting TLE on pretest 12. (link) Since the test case is too big, it's not shown completely but I think the string is 200000 z's. When I tried such an input on my computer, it shows 0.016 seconds. Why am I getting TLE there?edit: ok never mind, I changed a few characters randomly in the string and it took more than ~5s on my computer.
 » 9 months ago, # |   +1 What is the combinatorial solution for C? Anyone explain please.
 » 9 months ago, # |   +6 How come c++17 is much faster than c++14?Here 2 codes for D First Submission Second OneA whole half second seems rather cruel despite using scanf
•  » » 9 months ago, # ^ |   +3 This is just too cruel.
•  » » » 9 months ago, # ^ |   +6 Yeah totally shitty,candidate master gone cause of a simple weird mistake
 » 9 months ago, # |   0 Pretest 5 of D:4 4 21 1000000000..........2....1Can someone explain why the final state of the board is:2222222222212211rather than2222222122212111
•  » » 9 months ago, # ^ |   +3 And why would it be the second one? first player will only expand 1 cell up and 1 cell left in the first move (as his expansion speed is 1), and then the second player will fill out the board with his huge expansion speed.
•  » » » 9 months ago, # ^ |   0 Oh, I misunderstood this problem. I didn't realize that player i could take any square that was si distance away, I thought the problem meant that it could taken any squares si distance in the direction left, up, down, or right (i.e. could only expand in straight lines).I suppose I was confused because the problem said "castle", and I immediately imagined rooks from chess. Definitely much more my fault than the problem setter's, but still very annoying because I spent an hour of the contest looking for a bug in my code.
•  » » » » 9 months ago, # ^ |   +8 Alternating moves was not clear from neither the statement nor the sample tests, but they made an announcement regarding this.
•  » » » » » 9 months ago, # ^ |   0 Oh that's right, I do remember them making a statement about D. I was working on E and forgot about it. Stupid mistake.
•  » » 9 months ago, # ^ |   0 The first player only has 1 speed expansion, that means the state of board after the first player play is:..........21..11 Then, the second player plays filling the rest of the board.2222222222212211
 » 9 months ago, # | ← Rev. 2 →   -9 Why t can't be 0 in problem A ?
•  » » 9 months ago, # ^ |   +24 From problem statement:"The value of t is not fixed in advance and you can choose it as any integer."
•  » » » 9 months ago, # ^ |   +13 Thanks man. I wish I had seen it :(
•  » » » 9 months ago, # ^ |   +3 I too got WA first time. So read the question again and found this.
 » 9 months ago, # |   -12 It was a good contest with clear explanation of the problem.
 » 9 months ago, # |   0 Can someone help me find bug in this code for Div2D : 48619139
 » 9 months ago, # |   +4 Could anyone solve C using combinatorics (without DP)?
 » 9 months ago, # |   0 What a nice planning. I have to wait just 2 days for comeback :D
 » 9 months ago, # |   0 why this code for problem D get WA on test 38? https://codeforces.com/contest/1105/submission/48642621
 » 9 months ago, # |   +8 For problem C:I kept on trying it with stars and bars method, DP didn't occur to me.
•  » » 9 months ago, # ^ |   0 I used divide and conquer with memoization.
 » 9 months ago, # |   0 I think worst case complexity of D will be O(n*m) (In each chance if we acquire a cell) Player x will not play again in subsequent rounds if he wasn't able to play in previous round.
 » 9 months ago, # |   0 Is it just me, or this div2 round was a lot more accessible than most of other div2 rounds (even considering only the div2 only rounds)? I am curious about other people's opinions!
•  » » 9 months ago, # ^ |   +5 i agree with you strike ,it seems problem c was easier as more than 2000 contestants were able to solve it and problem b was also easier than a lot of div 2 rounds
 » 9 months ago, # |   0 In problem A, I got many WA because tried to find the minimum changing cost first. Tutorial say that we should find "t" value first. Why?
•  » » 9 months ago, # ^ |   0 because it is easier to find the value of the required "t" ,i also was doing the same then i realised that the constraints allow us to calculate the min value for all the possible values of "t" as "t" can only vary from 1 to 100 according to the values given in array , so our solution is just calculating all the min values for all the "t" keeping the one with min value as our solution which will give us time complexity of t*n.
•  » » » 9 months ago, # ^ |   0 got it. Thank you!
 » 9 months ago, # | ← Rev. 7 →   0 Deleted
 » 9 months ago, # |   0 time limit for D was too strict, no python solution passed the TLE during the contest.you can check out my python2 implementation of intended solutions gets TLE at test case 13also all these other solutions from other users in python3 got TLE even if most of them are correct as in the editorial TLE test case 13TLE test case 13TLE test case 13EDIT: I implemented a solution using collections.deque but still gets TLE, is anyone able to get AC on problem D using Python? up to now no one did.
 » 9 months ago, # |   0 In Problem B, Zuhair and Strings.Is n=200000 and k = 100000 a special case? If yes, I don't get it.After contest, I just added this case, and it is accepted(without any change of logic in previous submissions)
•  » » 9 months ago, # ^ |   0 No, n=200000 and k = 100000 is not a special case. I tried to run your submission with this testcase "6 3 abaaba" and it gave 2 as a result. the correct answer should be zero. "all characters of these x substrings are the same (i.e. each substring contains only one distinct character and this character is the same for all the substrings)."
 » 9 months ago, # | ← Rev. 2 →   0 Such a strangle thing. After contest I submit haosc1212's submission.48632510.And I got TLE.But the code accepted with 1600ms.How can this happen? Oh,C++17 is much faster than C++11.
 » 9 months ago, # |   +3 What is testcase 45 of problem D?
•  » » 9 months ago, # ^ |   +8 Generator's source code#include using namespace std; #define ll long long #define f(i, x, n) for(int i = x; i < (int)(n); ++i) int const N = 1000; char g[N][N + 1]; int main(){ printf("%d %d %d\n", N, N, 9); f(i, 0, 8)printf("%d ", 1000000000); printf("%d\n", 1); f(i, 0, N)f(j, 0, N)g[i][j] = '.'; f(i, 1, 10)g[i - 1][0] = '0' + i; for (int j = 1; j < N; j += 2){ f(i, 0, N)g[i][j] = '#'; if (!((j >> 1) & 1))g[N - 1][j] = '.'; else g[0][j] = '.'; } f(i, 0, N)printf("%s\n", g[i]); } 
 » 9 months ago, # | ← Rev. 2 →   0 Can test inputs and outputs be found somewhere on Codeforces after a contest ends? As you know, for large input or output, all of it may not be displayed on submission pages. Actually it's not related only to this contest.
 » 9 months ago, # |   0 Couldn't understand why I got TLE in problem D. I have attached both my contest time code (in which I got TLE in main test) and AC code written after contest. The only difference is I added this line " if(v[cur].empty()) return ret; " at the beginning inside bfs() function. But if I don't do this it should return the same "ret" since both v[cur] and q should be empty and no while loop should run. But adding this line is giving me AC in 0.5 sec while skipping this giving TLE with 2 sec+. What's the reason behind this significant difference in time? TLE Code: 48636948 AC Code: 48646138
•  » » 9 months ago, # ^ |   +3 It may got optimized. C++ is very hard to understand completely.
•  » » 9 months ago, # ^ |   +3 in case 45, bfs is called around nmp times, now each time you call bfs you create a new queue, I don't know the details, but creating a queue in c++ is not very fast which is why you get tle, changing that queue to global should greatly decrease the running time.
•  » » » 9 months ago, # ^ |   +17 The default container for a queue is deque, and for some reason it is more heavy than other data structures. The size of an empty queue (with deque container) is 80 bytes, while if we change the container to list, it will be 24 bytes.The same solution gets accepted after changing the container to list: queue > q — 48669305.So I think it is mainly memory allocation / deallocation that makes it too slow. The solution is declaring around 80 * 9 * 106  =  ~686 MB while using list container would declare 0.3 of that.
•  » » » 9 months ago, # ^ |   0 I use C++11 and then I got failed on system test.(i.e.TLE in test 45).And when I changed to use C++17.I got Accepted with 1600ms.How can C++11 and C++17 have so big differences. Maybe C++17 std::queue is optimized