| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Good test | Yermak | 1312. Тарелки | 4 июн 2026 15:25 | 2 |
600 400 152 63 152 Solution exists. |
| AC at least, but for me this problem very strange! | xurshid_n | 1553. Caves and Tunnels | 4 июн 2026 12:33 | 3 |
Heavy-Light-Decomposition -> GOOD data structure! thank you all! sqrt(n) decomposition also works here (0.5 sec) and easier to implement it's actually does not differ much because heavy-light with segment/fenvick over chains will be something like Q*log^2(N) with bad constant over it Actually it was the other way around :) except for ram usage SQRT: 0.437 11 532 KB HLD: 0.296 14 784 KB |
| Stack Overflow | Night | 1553. Caves and Tunnels | 4 июн 2026 11:33 | 4 |
Please I got Crash(Stack Overflow), I implemented my first heavy-light descomposition and tried this problem, but I got this. I got AC, I had to convert the DFS to BFS, to evade the StackOverflow. Edited by author 02.11.2011 04:45 Edited by author 02.11.2011 07:20 Edited by author 02.11.2011 08:20 {$m 100000000000000000000} You can use "G++ 9.2 x64" language to avoid it You can also use #pragma comment(linker, "/STACK:16777216) for MSVC and both heavy-light or sqrt decompositions can be performed with BFS, so no recursion needed |
| Hint for WA #8 | Vedernikoff 'Goryinyich' Sergey (HSE: АОП) | 1524. Men in Black | 3 июн 2026 22:56 | 1 |
Hint for WA #8 Vedernikoff 'Goryinyich' Sergey (HSE: АОП) 3 июн 2026 22:56 Likely some rounding issue, e.g. in Python int(x + 0.5) => WA #8 int(x + 0.5 + 1e-9) => AC |
| hints (Nostradamus advised this) | Dmi3Molodov | 1401. Игроки | 3 июн 2026 16:47 | 1 |
using u32=unsigned; u32 constexpr M = 9; u32 n = 0, g[1<<2*M]; template<u32>void solve(u32, u32=0); template<>void solve<2>(u32 voidXY, u32 BaseXY){ u32 e = n++, *p = g+BaseXY, q = g[voidXY]; *p = e, p[1] = e, p += 1<<M, *p = e, p[1] = e, g[voidXY] = q; } template<u32 s> void solve(u32 V, u32 B){ auto constexpr f = solve<s/2>; u32 constexpr m = (1<<M)-1; bool a = (V&~m)<(B&~m)+(s<<M)/2; bool b = (V&+m)<(B&+m)+s/2; f(V, B+(!a)*(s<<M)/2+(!b)*s/2); f(B-a*(1<<M)+b+((s<<M)+s)/2-1, B-a*(s<<(M-1))+b*s/2+(s<<M)/2); f(B+a*(1<<M)+((s<<M)+s)/2-(1<<M)-1, B+a*(s<<M)/2); f(B+a*(1<<M)+((s<<M)+s)/2-(1<<M), B+a*(s<<M)/2+s/2); u32*c = g+((s<<M)+s)/2-(1<<M)+B; c[m+(b&!a)] = c[(a&b)-1] = c[a<<M] = n++; } //this is a very funny, but working program code. Edited by author 03.06.2026 19:49 |
| WA #3 | 👨🏻💻 Spatarel Dan Constantin | 2139. Эксперимент с соком | 2 июн 2026 03:13 | 1 |
WA #3 👨🏻💻 Spatarel Dan Constantin 2 июн 2026 03:13 Input: 3 -6 -9 9 -1 0 5 1.5 -5.0 2 -155 -292 Output: 11.571429 0.000000 0.000000 |
| TL 17 | ~'Yamca`~ | 1623. Fractal Labyrinth | 1 июн 2026 23:09 | 1 |
TL 17 ~'Yamca`~ 1 июн 2026 23:09 you can decompose path (i -> j) like (i -> x) + (x -> y) + (y -> j) or like (i -> y) + (y -> j) |
| Tests | 👨🏻💻 Spatarel Dan Constantin | 1909. Космическая разведка | 1 июн 2026 18:42 | 1 |
Tests 👨🏻💻 Spatarel Dan Constantin 1 июн 2026 18:42 WA #13: 2 -4 -2 2 10 10 4 -2 -6 -4 1 -3 10 > Warning WA #53-58: 987 887 165 624 -588 687 71 516 -557 926 960 882 836 > False alarm WA #75: -14293 4710 59090 99004 48305 96853 -727 -55911 60157 -71916 -57144 -62493 2339 > Warning Edited by author 01.06.2026 22:05 |
| physically incorrect tests | Dmi3Molodov | 1930. Машина инженера Ивана | 31 май 2026 02:21 | 1 |
Explain example number two. How can you always move up or always down and arrive at the starting point? It's impossible!!! |
| Good problem! | Felix_Mate | 1752. Дерево 2 | 30 май 2026 14:16 | 6 |
I got AC with O(N*sqrt(N)),but my solution is very hard(274 lines and many different subtasks). Who can say simple solution(idea without code)? Hi. This is my solution for this problem. Let's find two farthest nodes in tree. Let's call it f1 and f2. It can be done by two bfs'. Now let's answer for queries. Let the y farthest node from x(it's f1 or f2). If such node exists that dist(x, z) = d, then it would lie on path from x to y. If dist(x, y) < d, answer would be 0. Let l be lca(x, y). If dist(l, x) <= d, answer would be dist(l, x)'th parent of x. If x is ancestor of y, answer would be (dist(x, y) - d)'th parent of y. Otherwise answer would be dist(l, y) - (d - dist(l, x)). Sorry for my poor English. O(N*log(N)), ~100 lines of code, ~1K gzipped For every edge out of a node we calculate L, the length of the longest path from this node thru the edge. It is two DFS: the first one to calculate L for downward edges, the second one to fix the upward edges. At most two edges (with the largest L) of each node are needed to calculate the longest paths (the second is needed for the situations where we get from node A into node B and in node B the edge B->A has the maximal L). For these two edges we precalculate short-cuts: for all i, such that 2^i ≤ L, we save the node C that can be reached after 2^i steps and from which edge in C it was reached. My solution is quite simple, just find one farthest nodes pair in the tree by two DFSs, denoting f1 and f2. Then use f1 as root and dfs to calculate the 2^i steps' father of every node x. And use f2 as root similarly. Then the answer can be done by express d to the binary form and jump at most log(n) to find an answer under these two roots. We can actually solve it on just O(N) time. Let's set vertex 1 as a root. Now let's at first find the depths of subtree of each vertex, deepest vertex in each subtree and the distance from the root for each vertex. This can be done in one DFS. Let's name them as: 1) depth[ver] -> depth of a subtree of vertex ver 2) dist[ver] -> distance from vertex 1 to vertex ver 3) mx_ver[ver] -> deepest vertex in a subtree of vertex ver Now we can check for all queries: 1) If query is (v, d) and depth of vertex v is >= d, then the answer is the parent of vertex mx_ver[v] on distance (depth[v] - d) (so we should somehow later go up from vertex v to (depth[v] - d) edges). Let's store it in mx_ver[v]. 2) If query is (v, d) and distance from root to v >= d (so dst[v] >= d), then the answer is the parent of vertex v on distance d, let's store this information in vertex v. What should we do with all the other queries? All other queries (v, d) tell us that the answer for them will look somehow like this: Take vertex v, go up several edges, then go down to some other subtree. So we need to take some ancestor of v and go into it to a subtree different from a subtree containing vertex v. Let's say that this ancestor is some vertex u and the depth of its deepest subtree not containing v is H. Then if (dst[v] - dst[u] + H) >= d, we can choose u as a suitable ancestor. And the answer for the query will be the parent of the deepest vertex in subtree H on distance d - (dst[v] - dst[u] + H). Great thing about these formulas is that if we stay in some vertex v during some DFS, for all our ancestors the number (H - dst[u]) is a constant and we can keep the maximum value of it on current path. So what should we do next? Let's simply run one more DFS. During our walk through the tree in the DFS let's keep maximum value of (H - dst[u]) for all our ancestors. To do this we need to do some routine stuff: 1) Calculate two maximums by depth[to] + 1 for all children (if we will go to the subtree with first maximum, we will use H - dst from the second one). 2) Before going into some child check if the new found values are larger then global maximum (H - dst[u]). 3) Not forget to carefully restore this global maximum going up on each step. 4) Each time we take new maximum for (H - dst[u]), also store the deepest vertex in the subtree H. Then in each vertex during this DFS we also need to iterate through all remaining queries for this vertex and try to set an answer to them, again in form "Answer for this query is a parent of some deepest vertex in some subtree H on distance (dst[v] + (H - dst[u])) - d" The final step would be to run one more DFS and in all vertices with stored info "go up to distance X" do this by simply storing current DFS path and writing needed parent as an answer for the corresponding query. |
| why i have Runtime error (stack overflow) with Visual C++ x64, but AC with G++ 9.2? | >>> | 1752. Дерево 2 | 30 май 2026 14:13 | 2 |
Why is there such a big difference between these two compilers and how do I know if I have solved this problem, it just feels like I wrote really dirty code and it somehow worked. #pragma comment(linker, "/STACK:16777216") |
| WA #23 | 👨🏻💻 Spatarel Dan Constantin | 1616. Квадратная страна 4 | 29 май 2026 23:58 | 1 |
WA #23 👨🏻💻 Spatarel Dan Constantin 29 май 2026 23:58 In test 23 the alpha angle is very close to 0 or 90. |
| If WA#6 | Timur Sitdikov (MSU Tashkent) | 1637. Игра в треугольник 2 | 29 май 2026 13:48 | 2 |
If WA#6 Timur Sitdikov (MSU Tashkent) 8 июл 2011 11:43 Try this: 0 0 1 0 0 2 0 0 -1 0 0 -2 2 Re: If WA#6 👨🏻💻 Spatarel Dan Constantin 29 май 2026 13:48 Input: 1 1 5 1 4 2 -1 -1 3 -1 2 -2 Output: 3 |
| Hint | Dmi3Molodov | 1868. Конкурс прогнозов | 28 май 2026 21:15 | 1 |
Hint Dmi3Molodov 28 май 2026 21:15 solve the problem ONLY if you are VERY diligent. |
| N = 1 | coder | 2168. Руны в поле | 28 май 2026 21:06 | 1 |
N = 1 coder 28 май 2026 21:06 What should be when N= 1 ? answer is 0 ? |
| Many many tests | andreyDagger`~ | 1955. Шеф, а я вас вижу! | 28 май 2026 13:12 | 2 |
These tests didn't help me figure out the issue, but maybe they can be useful for community 7 0 0 0 2 1 1 1 3 3 1 0 -1 -1 0 3.95284707521047407042 6 0 1 1 2 0 2 -1 1 -1 0 1 0 2.82842712474619029095 7 2 0 2 3 -2 3 -2 0 -2 -2 0 -2 2 -2 6.40312423743284853117 3 0 0 1 0 0 1 1.41421356237309514547 8 1 2 1 3 2 2 2 1 1 0 1 1 0 1 0 2 3.00000000000000000000 12 2 0 1 1 0 1 1 0 0 -2 -1 1 -1 2 0 2 -1 3 -4 0 0 -4 0 -1 6.79869268479037932229 12 2 0 1 1 0 1 1 0 -2 0 -1 1 -1 2 0 2 -1 3 -4 0 -3 -1 0 -1 6.00000000000000000000 7 0 0 1 2 1 1 3 1 1 -1 1 -3 -1 0 5.00000000000000000000 16 3 0 4 1 3 1 3 2 2 2 2 1 1 1 1 2 0 2 0 1 -1 1 -1 2 -2 2 -2 1 -3 1 -2 0 7.00000000000000000000 Be careful! The test with the supposed answer 6.79869268479037932229 is invalid because it self-intersects! |
| WA 19 | 🎧 Vadim Barinov \Frez_Fstilus/'``' :) | 2112. Полевые логи | 27 май 2026 14:56 | 1 |
WA 19 🎧 Vadim Barinov \Frez_Fstilus/'``' :) 27 май 2026 14:56 Test: 12 A B C D E F G H I J K L 12 A HIT B IN HEAD A REVIVE B C HIT D IN HEAD C REVIVE D D HIT E IN HEAD D REVIVE E F HIT G IN HEAD F REVIVE G G HIT H IN HEAD G REVIVE H I HIT J IN HEAD I REVIVE J Answer: CORRECT A B I J C D E K F G H L |
| Heavily incorrect russian statement | Igor Parfenov | 1288. Астролокация | 27 май 2026 04:17 | 1 |
There are a lot of mistakes in russian statement. I don't think, that is makes sense to write all of them - just read the english statement. |
| WA #25 | 👨🏻💻 Spatarel Dan Constantin | 1271. Лоцман | 26 май 2026 17:33 | 1 |
WA #25 👨🏻💻 Spatarel Dan Constantin 26 май 2026 17:33 Input: 100 100 0 10 10 10 0 0 19 11 1 10 10 20 10 20 20 Output: -1 |
| WA #2 | Rouk | 1304. Параллелепипед | 26 май 2026 03:51 | 3 |
WA #2 Rouk 19 авг 2012 00:07 no point of S lies in G (but may lie on its side) |