Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8103379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:32:01+00:00 2026-06-05T23:32:01+00:00

I don’t know how to write the title for this question. The existing title

  • 0

I don’t know how to write the title for this question. The existing title may not be precise.

Here is the problem:

I have m groups (arrays), say, 4 groups. Each group contains some numbers. What we wish is that each group gives one number out, and totally the resulting 4 numbers (each from one group) are distinct.

Now given these 4 groups, how can I make sure they fit to our wish?


For example,

A: 0, 2, 3

B: 0, 2

C: 2, 3

D: 1

The above 4 groups can fit to our wish. D gives 1, C gives 3, B gives 2, A give 0.


But if

A: 2

B: 2

C: 2, 3

D: 1

are bad. We can’t let each group give an distinct number.


My idea is the most stupid way that I just do backtrack on all elements from all groups to get every combination of elements and see those elements from one combination are distinct or not.

Anyone has better idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:32:03+00:00Added an answer on June 5, 2026 at 11:32 pm

    You can model this as a network flow problem and then use a fast algorithm in that problem domain (many of which are polynomial time) like Edmunds-Karp or push-relabel.

    Create a source node and a sink node. Then create nodes for each “group” and for each distinct element. Connect each group node to the source and each element node to the sink. Finally connect group nodes with element nodes if the group as the element. All flow capacities should be 1.

    This is best illustrated with an example. I’ll use the first example you gave:

    A: 0, 2, 3
    B: 0, 2
    C: 2, 3
    D: 1
    

    Will turn into the following flow network:

       A   0
      /     \
     /       \
    S--B   1--T
     \       /|
      \     / |
       C   2 /
            /
           3
    

    I couldn’t draw the intermediate flows. But imagine that A flows to 0, 2, 3, and B flows to 0, 2, and C flows to 2, 3, and D flows to 1. All flows are unit capacity.

    So first find the max-flow in this graph. The flows between the groups and elements will give you the bipartite matching that you want.

    If there isn’t a possible matching, then the max-flow will be less than the number of groups.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

don't know better title for this, but here's my code. I have class user
I don't know if this question is trivial or not. But after a couple
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
Don't know if this has been asked before, so point me to another question
Don't know if this is an eclipse specific problem but whenever I declare a
I don't know why this double json response are not successful: [{first_content:content,...}][{second_content:content,...}] So i
Don't know if this has been answered before. Have custom routes to users. If
Don't know why but I can't find a solution to this. I have 3
Don't know a better title but here is what im trying to do. I
don't know if the title describes anything about what I'm trying to say but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.