欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

Girls and Boys

系統 1863 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條評論
主站蜘蛛池模板: 最新国产网址 | 久久艹逼 | 国产免费叼嘿在线观看 | 亚洲精品久久久久一区二区 | 日韩免费一区二区三区 | 日本一区二区在线视频 | 桃色网站入口 | 91视频观看免费 | 国产精品99久久久久久久女警 | 无码日本亚洲一区久久精品 | 日韩成人在线视频 | 欧美在线一级片 | 好爽好大www视频在线播放 | 欧美一区二区三区在线可观看 | 欧美精品在线观看 | 四虎1515hhhcom| 国内精品免费一区二区观看 | 久章草影院 | 天天拍天天干 | 免费看毛片网 | 午夜欧美性欧美 | 亚洲性在线观看 | 91在线观看视频 | 欧美成年性h版影视中文字幕 | 欧美成人免费高清二区三区 | 久久久久成人精品 | 久久福利 | 色综合网亚洲精品久久久 | 日韩精品无码一区二区三区 | 成年人在线观看视频网站 | 久久新网址 | 日韩电影一区二区三区 | 亚洲综合精品成人 | 亚洲国产成人av好男人在线观看 | 欧洲成人精品 | 91天堂| 日韩精品一区二区三区中文3d | 精品国产一区二区三区久久影院 | 不卡在线一区 | 日本捏胸摸下面免费视频 | 欧美一区二区在线观看 |