ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1272. Non-Yekaterinburg Subway

Roma Labish[Lviv NU] I think, my algo is correct, but I still wa2 [7] // Problem 1272. Non-Yekaterinburg Subway 11 Feb 2007 22:13
Lets graph G has n vertices and k components => number of m edges meet the conditions:
n-k <= m <= 1/2(n-k)(n-k+1).
Therefor k >= n-m. So, min(k) = n-m.
We have number of islands = N, and number of tunnels K. Why the answer isn't N-K-1 ?

Edited by author 11.02.2007 22:13
Try this test
4 5 0
1 2
1 3
1 4
2 3
3 4
Answer 0, your answer 4 - 5 - 1 = 2
or this
5 4 1
1 2
3 4
4 5
3 5
2 3
Answer 1, your answer 5 - 4 - 1 = 0
Roma Labish[Lviv NU] Re: I think, my algo is correct, but I still wa2 [5] // Problem 1272. Non-Yekaterinburg Subway 5 Mar 2007 01:03
Why for the second test answer is 1? There is only one component, so you shouldn't to add any edges. And one more thing, if n < k answer is 0. So what's wrang?
In your case, 'wrang' is wrong :)
5 4 1
1 2
3 4
4 5
3 5
2 3

Count of tunnels is 4. So graph with edges 1 2, 3 4, 4 5, 3 5 have 2 components. You should use exactly one bridge (edge 2 3) to make it connected.
Read problem statement more carefully.
Task is to delete maximal number of "bridges" in given graph.
Ok! Thank. I'll try to find another way to solve it.
I had done it:) Thanks to all for help!!!