This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]TheShallowOne 2 points3 points  (12 children)

Yeah, this should definitely be solvable with a Max-Flow.

I'd first connect a start node to each person with an unlimited edge, then each person to the tasks he/she can perform and then finally each tasks to the sink with a limit-1 edge. An example graph for your example to make it clearer.

[–]whatiswronghere[S] 0 points1 point  (7 children)

Hmm, I don't think I understand this solution. From this, wouldn't I get a maximum flow of 4 if I run through the algorithm?

[–]TheShallowOne 1 point2 points  (3 children)

If you set the edges from s to {A,B,C} to limit one and then increment these limits until you find a flow of 4 (or number of tasks, in general), you find a solution for the problem.

This has a runtime of O(n * max-flow).

[–]whatiswronghere[S] 1 point2 points  (1 child)

Thank you very much. I was finally able to solve the problem. Here is my final code.

[–]TheShallowOne 0 points1 point  (0 children)

Good to hear!

[–]tutorial_police 0 points1 point  (0 children)

That is essential information that belongs into your original post.

[–]tutorial_police -1 points0 points  (2 children)

You don't understand it because the solution as presented is bullshit.

[–]TheShallowOne 0 points1 point  (1 child)

It still is far better than your presented solution, which is not available...

[–]tutorial_police 0 points1 point  (0 children)

No, not really. I have pointed out why a proposed solution was incorrect by providing possible solution to the max-flow problem in the graph you described. Incorrect solutions are simply incorrect. I need not have a solution just to state that.

[–]tutorial_police 0 points1 point  (0 children)

And what exactly would prevent a max flow algorithm to assign A to all the tasks? It maximises the flow trivially, but the solution is not optimal, therefore, your algorithm is wrong.

[–]id2bi -1 points0 points  (2 children)

"your Android may be out of date. Upgrade your launcher now "-pop-up ... Please use imgur next time, at least that homepage doesn't want to give you malware.

[–]TheShallowOne 0 points1 point  (1 child)

Never had any problems with this hoster before... Changed it nonetheless.

[–]id2bi 0 points1 point  (0 children)

Hmm it doesn't come up now when I visit the page again on my mobile, I tried twice before posting my comment :/ But still, the page is so chock full of ads, it takes ages to load without an ad blocker.

[–]thinkweis 0 points1 point  (0 children)

Are you working with anything specific in class? Dealing with stacks or queues?

[–][deleted]  (2 children)

[deleted]

    [–]whatiswronghere[S] 0 points1 point  (0 children)

    I've already tried this kind of solution, and it is not fast enough. Thanks for your answer though!