|
|
Общий форумIf you have wa8, check precision, maybe this will help you. Finally, I did setprecision(100) and get ac. Btw, this task can be solved with one dfs without rerooting. I tried a lot of variations of self-made stacks but all of them failed. Then I just used 1000 std::stacks with Visual C++ 2022 compiler (not x64) and it worked, using only 640 KB of memory. Most probably could be solved with centroid decomposition (didn't think much but have some ideas). But my solution is with tree dp with top to bottom dfs and bottom to top dfs. Some call is "rerooting". Use long type (anything 64 bit) MST It ain't a problem to include all the tunnels because apparently they have no cost. So include all of them and then count the number of connected components (let's call it l). The answer is not dependent to the bridges. It is just l-1. Just check if the condition for the i-th node is correct in the given order. That's it. ~8 lines or something. If you are unfamiliar, I recommend to google binary search trees. queues dont equal length like 1 2 3 4 and next person want to insert between 1 and 2, you dont let him to do that I have same problem. See you'v done it. What's wrong? Give please same tests. You solved problem. Thanks. Edited by author 17.08.2015 12:01 Edited by author 17.08.2015 12:01 7.503 2.501 ans: 25.000003 "If it is not possible to construct the fence from the specified blocks, write 0.00." - dementia binary search from the maximum side across the floors to infinity is a bad idea - a ternary search is better suited, it can be run over all segments equal in length to the root from infinity, and also for prevention it is worth adding a few additional random segments (about 10,000) I would highlight a few good infinities such as 5e6, 1e8, 1e10, 1e6, 1e5, 2.625e6 The order of the walls is not important #define ld long double ld arcsin(ld k) { if (k >= 1) { k = 1; } if (k <= -1) { k = -1; } return asinl(k); } (I hope you won't need this feature.) i think 1e-10 nice eps, but i dont sure Test 45 requires no changes. Just print input data in this case. use bitsets for quick restoring the answer Check if your code works correctly if there is only one meal in the restaurant 1 1 answer: 1 1 -1 answer: 0 Just realization problem, really easy. Rating is too big. Easy solution using 0.14 seconds, first try. Just realization with Python. Why rating is so big? |
|
|