亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Girls and Boys

系統 1795 0

Girls and Boys

Time Limit: 20000/10000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5565????Accepted Submission(s): 2481

?

Problem Description
the second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is defined between one girl and one boy. For the study reasons it is necessary to find out the maximum set satisfying the condition: there are no two students in the set who have been “romantically involved”. The result of the program is the number of students in such a set.

?

The input contains several data sets in text format. Each data set represents one set of subjects of the study, with the following description:

?

the number of students
the description of each student, in the following format
student_identifier:(number_of_romantic_relations) student_identifier1 student_identifier2 student_identifier3 ...
or
student_identifier:(0)

?

The student_identifier is an integer number between 0 and n-1, for n subjects.
For each given data set, the program should write to standard output a line containing the result.
?

?

Sample Input
7
0: (3) 4 5 6
1: (2) 4 6
2: (0)
3: (0)
4: (2) 0 1
5: (1) 0
6: (2) 0 1
3
0: (2) 1 2
1: (1) 0
2: (1) 0
?

?

Sample Output
5
2
?

?

Source
Southeastern Europe 2000
?

?

Recommend
JGShining

嗯,看起來是個求最大獨立集的題,而且還是個二分圖.因為題里沒說有 Homosexuality,所以不會有奇環.不過圖是用一般形式給出的算出來的匹配要除以2.

?

      #include<stdio.h>
      
        

#include
      
      <
      
        string
      
      .h>


      
        int
      
       n,m,match[
      
        1024
      
      
        ];


      
      
        bool
      
       visit[
      
        1024
      
      ],G[
      
        1024
      
      ][
      
        1024
      
      
        ];


      
      
        bool
      
       DFS(
      
        int
      
      
         k)

{

    
      
      
        int
      
      
         t;

    
      
      
        for
      
       (
      
        int
      
       i=
      
        0
      
      ;i<m;i++
      
        )

    
      
      
        if
      
       (G[k][i] && !
      
        visit[i])

    {

        visit[i]
      
      =
      
        1
      
      
        ;

        t
      
      =
      
        match[i];

        match[i]
      
      =
      
        k;

        
      
      
        if
      
       (t==-
      
        1
      
       || DFS(t)) 
      
        return
      
      
        true
      
      
        ;

        match[i]
      
      =
      
        t;

    }

    
      
      
        return
      
      
        false
      
      
        ;

}


      
      
        int
      
      
         Max_match()

{

    
      
      
        int
      
       ans=
      
        0
      
      
        ;

    memset(match,
      
      -
      
        1
      
      ,
      
        sizeof
      
      
        (match));

    
      
      
        for
      
       (
      
        int
      
       i=
      
        0
      
      ;i<n;i++
      
        )

    {

        memset(visit,
      
      
        0
      
      ,
      
        sizeof
      
      
        (visit));

        
      
      
        if
      
       (DFS(i)) ans++
      
        ;

    }

    
      
      
        return
      
      
         ans;

}


      
      
        int
      
      
         main()

{

    
      
      
        int
      
      
         t,a,b,c;

    
      
      
        while
      
       (scanf(
      
        "
      
      
        %d
      
      
        "
      
      ,&t)!=
      
        EOF)

    {

        n
      
      =m=
      
        t;

        memset(G,
      
      
        0
      
      ,
      
        sizeof
      
      
        (G));

        
      
      
        while
      
       (t--
      
        )

        {

            scanf(
      
      
        "
      
      
        %d: (%d)
      
      
        "
      
      ,&a,&
      
        b);

            
      
      
        for
      
       (
      
        int
      
       i=
      
        0
      
      ;i<b;i++
      
        )

            {

                scanf(
      
      
        "
      
      
        %d
      
      
        "
      
      ,&
      
        c);

                G[a][c]
      
      =
      
        1
      
      
        ;

            }

        }

        printf(
      
      
        "
      
      
        %d\n
      
      
        "
      
      ,n-Max_match()/
      
        2
      
      
        );

    }

}
      
    

?

?

?

Girls and Boys


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 狠狠色丁香婷婷久久综合2021 | 亚洲91色 | 欧美专区在线 | 四虎在线免费视频 | 免费精品国产福利片 | 日日夜夜摸 | 色综合亚洲综合网站综合色 | 亚洲人成毛片线播放 | 69做爰视频在线观看 | 日本强日本不卡一 | 一级毛片免费观看久 | 奇米在线观看 | 老子影院无码午夜伦不卡 | 91在线精品 | 黄色小视频在线免费观看 | 乱人伦中文视频在线 | 爱爱视频免费网站 | 久久黄视频 | 国产亚洲欧洲国产综合一区 | 99热久久国产精品这里有全部 | 国产精品久久久免费视频 | 精品日韩二区三区精品视频 | 精品久久久久久婷婷 | 无遮挡又黄又爽又色1000部 | 99热国产这里只有精品免费 | 99视频在线免费 | 日本黄色录像视频 | 直接看的毛片 | 日本一区二区在线 | 全黄冷激性性视频 | 婷婷在线观看网站 | 三极毛片 | 久久综合五月 | 99精品国产高清一区二区麻豆 | 黄频网站在线观看视频 | 国产成人一区在线播放 | 欧美成人手机在线视频 | 久久精品人人做人人爱爱 | 欧美成人免费毛片 | 四虎视频在线 | 91在线视频免费91 |