First to go over the solution quickly (skip down a few paragraphs if you already know the solution): one can use binary search to reduce the range of possible locations for the train to a constant multiple ofK, such as6K. Just make sure to expand out both ends of the range byKafter e...
Having spent a number of Codeforces rounds practicing the ins and outs ofRust, I think it's finally safe to encourage wider participation in the language! This guide is intended primarily for C++ programmers who may have taken interest in Rust, but had doubts regarding its feasibility in timed...
The time limit is the most amount of time your solution will run on a single test. In case your solution takes more time to complete, you will receive a “Time Limit Exceeded” (TLE) verdict. If your solution gets time limit exceeded for a certain test, it will be run several times ...
Today I completed my second competition (#333) and an important question regarding time limits arose. I solved theB problemin O(n) time and after locking the problem, I saw that a participant in my room solved it in O(n^2) time. Consequently, I wanted to hack his solution based on...
The pattern of replacing DFSs by Floyd-Warshall is really common in TC, in which the number of nodes is almost always limited to 100 or less, so it's a good trick to know. I don't think this is a bad thing either -- if you know the solution by FW, you clearly know the solutio...
You may be asking yourself why the hack is the solution correct cause if we take B as the center we will count only 4 points. It is guaranteed that if the rightmost point from the right is taken as a center all the points on the right will be found. ↵↵Note: We could have ...
I tried to hack this solution, so I inputted graph 0-3-2-1, however my test was rejected, because problem was about trees and there was a constraint that parent of vertex i should be less than i and I didn't have time to come up with another testcase. Unexpectedly, this solution ...