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 | tourist | 3645 |

2 | Radewoosh | 3403 |

3 | LHiC | 3336 |

4 | wxhtxdy | 3329 |

5 | Benq | 3320 |

6 | Um_nik | 3301 |

7 | V--o_o--V | 3275 |

8 | mnbvmar | 3193 |

9 | yutaka1999 | 3190 |

10 | ainta | 3180 |

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

1 | Errichto | 192 |

2 | Radewoosh | 177 |

3 | rng_58 | 163 |

4 | PikMike | 162 |

5 | Vovuh | 161 |

6 | majk | 158 |

7 | 300iq | 154 |

8 | Um_nik | 151 |

9 | kostka | 149 |

10 | antontrygubO_o | 146 |

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-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Aug/17/2019 14:42:25 (g2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|