returns the intersection of two paths (a,b) and (c,d) {0,0} for null path
| 66 | // returns the intersection of two paths (a,b) and (c,d) |
| 67 | // {0,0} for null path |
| 68 | pair<int, int> path_intersection(int a, int b, int c, int d) { |
| 69 | if (a == 0 || b == 0) return {0, 0}; |
| 70 | int u = lca(a, b), v = lca(c, d); // splits both paths in two chains from lca to one node |
| 71 | pair<int, int> x, y; |
| 72 | x = getCommonPath(u, a, v, c); |
| 73 | y = getCommonPath(u, a, v, d); |
| 74 | pair<int, int> a1 = path_union_light(x, y); |
| 75 | x = getCommonPath(u, b, v, c); |
| 76 | y = getCommonPath(u, b, v, d); |
| 77 | pair<int, int> a2 = path_union_light(x, y); |
| 78 | return path_union_light(a1, a2); |
| 79 | } |
| 80 | int32_t main() { |
| 81 | int t, cs = 0; cin >> t; |
| 82 | while (t--) { |
no test coverage detected