In the problem; https://codeforces.com/contest/1586/problem/B m < n; how to solve the same problem if there is no restriction on m only just 3 <= m, n <= 2*10^5 and print -1 if such a tree is not possible

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

1 | tourist | 3870 |

2 | Benq | 3618 |

3 | Miracle03 | 3453 |

4 | peehs_moorhsum | 3430 |

5 | Radewoosh | 3418 |

6 | Petr | 3408 |

7 | maroonrk | 3387 |

8 | sunset | 3338 |

9 | ko_osaga | 3334 |

9 | jiangly | 3334 |

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

1 | YouKn0wWho | 214 |

2 | 1-gon | 203 |

3 | Um_nik | 195 |

4 | Errichto | 182 |

5 | awoo | 180 |

6 | sus | 176 |

6 | tourist | 176 |

8 | antontrygubO_o | 173 |

9 | maroonrk | 170 |

10 | -is-this-fft- | 169 |

In the problem; https://codeforces.com/contest/1586/problem/B m < n; how to solve the same problem if there is no restriction on m only just 3 <= m, n <= 2*10^5 and print -1 if such a tree is not possible

↑

↓

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/05/2021 08:18:30 (k1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

If there are no restrictions then you can literally draw any tree. Just print a linked list like tree. 1 — 2 -3 -.....- n-1 — n.

Its the restriction part which makes it a little bit trickier.

Comment of the Year

There are restriction but no restrictions on m. Learn to read the statements properly before answering.

I am sorry I can only solve problems not riddles. I still don't understand your entitlement and "There are restriction but no restrictions on m"

Task gives $$$1 \leq m < n$$$.

OP asks about $$$3 \leq m \leq 2\cdot 10^5$$$.

You assume OP asks about $$$m = 0$$$.

SpoilerThere, I solved your riddle.

can you please provide a tutorial with implementation?

The idea is to create the spider tree (having a central node, and the rest of the nodes connected directly by an artist to that central node) thus ensuring a minimum of possible violations to the given restrictions. What is the only node that can violate any of these conditions? Well, the central node of the degree (given that all possible connections between the nodes of the network have only it as an intermediate node). Therefore the solution would be to choose the central node under the condition that it is not one of the nodes

bof the constraints (thus ensuring that a condition is never violated).I hope I have explained myself well and that it helps you :)

you're a girl, kitchen is where you belong. Make sure you code in the kitchen.

solution for m <= n + 1