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.

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

1 | MiFaFaOvO | 3681 |

2 | Um_nik | 3544 |

3 | maroonrk | 3431 |

4 | tourist | 3409 |

5 | apiadu | 3397 |

6 | 300iq | 3317 |

7 | ecnerwala | 3260 |

7 | Benq | 3260 |

9 | LHiC | 3229 |

10 | TLE | 3223 |

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

1 | Errichto | 194 |

2 | antontrygubO_o | 191 |

3 | vovuh | 178 |

4 | pikmike | 174 |

5 | tourist | 166 |

6 | McDic | 164 |

6 | Um_nik | 164 |

8 | ko_osaga | 163 |

9 | Radewoosh | 162 |

10 | 300iq | 156 |

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: May/26/2020 03:03:07 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|