10480 - Sabotage
Moderator: Board moderators
-
- New poster
- Posts: 17
- Joined: Fri Aug 01, 2003 4:55 pm
- Location: Beijing, China
10480 - Sabotage
I want to use search but I think it's inefficient. Is there any efficient and
easy algorithm? Any hint is aprreciated.
easy algorithm? Any hint is aprreciated.
-
- New poster
- Posts: 17
- Joined: Fri Aug 01, 2003 4:55 pm
- Location: Beijing, China
10480 - test cases?
Does anyone have any test cases for this problem? It seems like it's just straight forward min-cut.
Thanks!
Code: Select all
Snip
Here's some test cases that I came up with. The solutions to these are not necessarily unique.
Input:
Output:
Input:
Code: Select all
5 8
1 4 30
1 3 70
5 3 20
4 3 5
4 5 15
5 2 10
3 2 25
2 4 50
5 8
1 4 30
1 3 70
5 3 20
4 3 5
4 5 15
5 2 10
3 2 25
2 4 50
7 8
1 3 1
1 4 2
1 5 2
3 6 2
4 6 1
5 7 1
6 2 2
7 2 2
4 5
1 3 1
1 4 2
3 4 1
3 2 2
4 2 1
4 5
1 3 1
1 4 3
3 4 1
3 2 2
4 2 1
4 5
1 3 1
1 4 4
3 4 1
3 2 2
4 2 2
7 8
1 3 10
3 4 3
3 5 3
3 6 3
4 2 4
5 7 4
6 7 4
7 2 4
5 4
1 3 10
1 2 20
1 5 30
1 4 40
0 0
Code: Select all
1 4
3 2
3 4
3 5
1 4
3 2
3 4
3 5
1 3
4 6
5 7
1 3
1 4
1 3
4 2
4 3
1 3
4 2
4 3
3 4
7 2
1 2
-
- Experienced poster
- Posts: 145
- Joined: Thu Aug 14, 2003 8:42 am
- Location: Mountain View, California
- Contact:
Re:
Use the cost as the capacity for each edge.sharklu2000 wrote:I know Max-flow, but it only calculates the minimum number of edges
to cut. How can I know the minimum cost?
Have you ever...
- Wanted to work at best companies?
- Struggled with interview problems that could be solved in 15 minutes?
- Wished you could study real-world problems?
Re: 10480 - Sabotage
Data set for this problem is weak,I think.As,The Graph is undirected.
Output for following should be:
My latest accepted approach Outputs:
But my another accepted(Not supposed to get accepted
) outputs:
which is definitely wrong.
Output for following should be:
Code: Select all
7 7
1 4 2
4 5 5
5 2 2
1 7 3
7 5 3
4 6 3
6 2 3
0 0
My latest accepted approach Outputs:
Code: Select all
1 4
1 7
![:D](./images/smilies/icon_biggrin.gif)
Code: Select all
1 4
5 4
5 2
-
- New poster
- Posts: 37
- Joined: Wed Mar 14, 2012 11:57 am
- Location: Bangladesh
- Contact:
Re: 10480 - Sabotage
This is the second problem I solved after learning flow algorithm. After figuring out that max flow is equivalent to min cut, the difficult part was finding a way to print the cuts. Read few books but it didn't help. Took me 3 days to find the following link. Hope it helps some one.
http://stackoverflow.com/questions/4482 ... -algorithm
http://stackoverflow.com/questions/4482 ... -algorithm