What should be the approach to find all paths with maximum flow? The graph is directed acyclic graph and the maximum number of nodes(vertices) in the graph can be 40 and edges around 80. Also, most of the edges have unit capacity.

Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years.
×

# | User | Rating |
---|---|---|

1 | MiFaFaOvO | 3681 |

2 | tourist | 3496 |

3 | apiadu | 3438 |

4 | TLE | 3356 |

5 | LHiC | 3339 |

6 | mnbvmar | 3281 |

7 | 300iq | 3267 |

8 | Radewoosh | 3242 |

9 | yosupo | 3233 |

10 | 1919810 | 3203 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 190 |

2 | antontrygubO_o | 186 |

3 | tourist | 182 |

4 | Radewoosh | 168 |

5 | vovuh | 167 |

6 | pikmike | 166 |

7 | ko_osaga | 161 |

7 | Um_nik | 161 |

9 | rng_58 | 156 |

10 | Petr | 154 |

Help needed in the following problem :

There are **N** (1<=N<=200000) line segments (end-point coordinates are positive integers less than **1e9**). The task is to merge the line segments that are * overlapping* and finally print the coordinates of all the merged line-segments.

Sample Test Case

N = 4

Line segments:

[(1,1) (5,1)]

[(4,1) (7,1)]

[(3,3) (9,3)]

[(5,3) (8,3)]

The answer for this test case would be :

[(1,1) (7,1)]

[(3,3) (9,3)]

**My Approach** : Consider each line segment as a vertex and make edges between segments U and V if U and V overlaps. Then, find the connected components. For each connected components, answer can be calculated by taking the min of left coordinates and maximum of right coordinates. But this approach is O(N^2) and will not work for N=200000.

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/27/2020 18:13:52 (g2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|