欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 一级做a爰片久久毛片唾 | 久久久久国产亚洲日本 | 一区二区三区四区亚洲 | 亚洲热综合 | 偷拍自拍五月天 | 小视频你懂得 | www.尤物视频 | 欧美电影大全 | 国产亚洲第一页 | 精品亚洲国产成av人片传媒 | 日本三级视频 | av日韩在线看 | 精品视频一区二区三区免费 | 色婷婷国产精品欧美毛片 | 国产大学生真实在线播放 | 国产精品久久久久久免费软件 | 99热在线精品观看 | 国产综合在线播放 | 国产黄的网站免费 | 日韩经典中文字幕 | 午夜成人免费视频 | 欧美日韩国产一区二区三区不卡 | 色网址在线 | 亚洲人成网站看在线播放 | dy天堂| 国产精品爱久久久久久久小说 | 一级大片免费看 | 一区二区三区在线 | 亚洲婷婷综合网 | 免费国产自久久久久三四区久久 | 奇米影视8888| 日本一本免费一二区 | 天天插天天干 | 91亚洲国产成人精品性色 | 成人性a激情免费视频 | 日韩欧美视频在线 | 色婷婷色综合缴情在线 | 成人午夜大片免费视频77777 | 免费观看国产大片资源视频 | 欧美日韩在线观看中文字幕 | av毛片在线免费看 |