• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            我希望你是我獨家記憶

            一段永遠封存的記憶,隨風而去
            posts - 263, comments - 31, trackbacks - 0, articles - 3
               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

            ZJU--1140--二部圖

            Posted on 2008-08-01 19:39 Hero 閱讀(182) 評論(0)  編輯 收藏 引用 所屬分類: 代碼如詩--ACM
            /* Accepted 1140 C++ 00:01.10 500K */
            //還是二部圖

            #include 
            <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <string.h>
            #include 
            <ctype.h>
            #define llong unsigned long long 
            #define unint unsigned int
            #define printline  printf( "\n" ) 

            const int INF = 1000000 ;
            const int size = 310 ;

            int testnum, ct ;
            int inp, inn ;
            bool link[size][size] ;

            int Binmatch( int inn, int inm )
            {
                
            int matchnum = 0 ; int dn_node ;
                
            int queue[size*10] ; int head=0, tail = 0 ;//定義隊列
                int upmatch[size], dnmatch[size] ; int prev[size] ;
                memset( upmatch, 
            -1sizeof(upmatch) ) ;
                memset( dnmatch, 
            -1sizeof(dnmatch) ) ;

                
            forint i=1; i<=inn; i++ ) {
                    
            forint j=1; j<=inm; j++ )    prev[j] = -2 ;
                    head 
            = tail = 0 ;

                    
            forint j=1; j<=inm; j++ )    if( link[i][j] )
                    { prev[j] 
            = -1 ; queue[tail++= j ; }

                    
            while( head < tail ) {
                        dn_node 
            = queue[head] ;
                        
            if-1 == dnmatch[dn_node] )    break ;
                        head
            ++ ;
                        
            forint j=1; j<=inm; j++ ) if-2==prev[j]&&link[dnmatch[dn_node]][j] )
                        { prev[j] 
            = dn_node ; queue[tail++= j ; }
                    }

                    
            if( head == tail )    continue ;
                    
            while( prev[dn_node] > -1 ) {
                        upmatch[dnmatch[prev[dn_node]]] 
            = dn_node ;
                        dnmatch[dn_node] 
            = dnmatch[prev[dn_node]] ;
                        dn_node 
            = prev[dn_node] ;
                    }

                    dnmatch[dn_node] 
            = i ; upmatch[i] = dn_node ;
                    matchnum
            ++ ;
                }

                
            return matchnum ;
            }

            int main()
            {
                
            //freopen( "frac1.in", "r", stdin ) ;
                
            //freopen( "frac1.out","w",stdout ) ;

                
            int sn, en, numlink ;
                
            while( scanf( "%d",&testnum ) != EOF )
                {
                    
            for( ct=1; ct<=testnum; ct++ ) 
                    {
                        memset( link, 
            falsesizeof(link) ) ;
                        scanf( 
            "%d %d",&inp, &inn ) ;
                        
            forint sn=1; sn<=inp; sn++ ) {
                            scanf( 
            "%d",&numlink ) ;
                            
            while( numlink -- ) {
                                scanf( 
            "%d",&en ) ;    link[sn][en] = true ;
                            }
                        }
            //data input

                        
            int matchnum = Binmatch( inp, inn ) ;

                        
            if( matchnum == inp )    printf( "YES\n" ) ;
                        
            else                    printf( "NO\n" )  ;
                    }
                }
            //while

                
            return 0 ;
            }
            国产美女亚洲精品久久久综合| 久久久久波多野结衣高潮| 久久99国产精品久久| 久久久精品波多野结衣| 久久精品国产男包| 亚洲国产精品人久久| 久久人人爽人人爽人人片AV高清 | 99久久99久久精品免费看蜜桃| 94久久国产乱子伦精品免费| 久久91精品国产91久| 2021国产成人精品久久| 日韩av无码久久精品免费| 香蕉久久永久视频| 亚洲综合精品香蕉久久网97| 久久亚洲日韩精品一区二区三区| 久久久久这里只有精品| 久久国产乱子精品免费女| 色欲久久久天天天综合网 | 精品久久久久久无码国产| 久久婷婷五月综合97色| 久久久噜噜噜久久中文字幕色伊伊 | segui久久国产精品| 99久久精品午夜一区二区| 久久天天躁狠狠躁夜夜不卡| 久久精品国产一区二区三区| 久久高潮一级毛片免费| 免费观看久久精彩视频| 精品久久一区二区三区| 久久久无码精品亚洲日韩按摩| 亚洲级αV无码毛片久久精品| 久久99热这里只有精品66| 亚洲欧美精品一区久久中文字幕| 四虎国产精品免费久久| 亚洲国产成人精品91久久久 | 亚洲AV日韩AV天堂久久| 日韩AV无码久久一区二区 | 久久精品国产2020| 久久久久久久亚洲Av无码| 97久久天天综合色天天综合色hd| 国产91色综合久久免费分享| 狠狠色丁香婷综合久久|