• <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>
            #include <iostream>
            #include 
            <vector>

            using namespace std;

            #define N 20010
            int n;
            vector
            <int> map[N];
            bool visite[N];
            int  ans, node;

            int dfs( int u )
            {
                
            int total= 0;
                
            int curmax= 0;
                
                
            for( size_t i= 0; i< map[u].size(); ++i )
                
            {
                    
            int v= map[u][i];
                    
            int t;
                    
                    
            if!visite[v] )
                    
            {
                        visite[v]
            = true;
                        t
            = dfs( v );
                        total
            += t;
                        
                        
            if( t> curmax ) curmax= t;
                    }

                }

                
                
            if( n- 1- total> curmax ) curmax= n- 1- total;    
                
            if( curmax< ans ) ans= curmax, node= u;
                
            else if( curmax== ans && u< node ) node= u;
                
                
            return total+ 1;
            }


            int main()
            {
                
            int test;
                scanf(
            "%d",&test);
                
                
            while( test-- )
                
            {
                    scanf(
            "%d",&n );
                    
            int a, b;
                    
            forint i= 1; i< n; ++i ){
                        scanf(
            "%d%d",&a,&b );
                        map[a].push_back(b);
                        map[b].push_back(a); }

                        
                    ans
            = 1<<30;
                    memset( visite, 
            falsesizeof(visite) ); visite[1]= true;
                    dfs( 
            1 );
                    printf(
            "%d %d\n", node, ans );
                    
                    
            forint i= 0; i<= n; ++i ) map[i].clear();
                }

                
                
            return 0;
            }

            posted on 2009-04-19 20:45 Darren 閱讀(349) 評論(0)  編輯 收藏 引用
            97久久精品无码一区二区 | 热综合一本伊人久久精品| 狠狠精品干练久久久无码中文字幕| 久久精品人人做人人爽电影| 欧美精品丝袜久久久中文字幕 | 久久精品国产2020| 国产精品久久久久国产A级| 国内精品久久久久国产盗摄| 亚洲色欲久久久久综合网| 久久国产色AV免费看| 久久免费大片| 色偷偷888欧美精品久久久| 一本久久综合亚洲鲁鲁五月天| 99精品国产在热久久| 久久这里的只有是精品23| 久久噜噜电影你懂的| 亚洲成色www久久网站夜月| 国产一级持黄大片99久久| 日本亚洲色大成网站WWW久久| 久久精品人成免费| 久久精品国产亚洲AV影院| 伊人丁香狠狠色综合久久| 久久久久亚洲精品无码蜜桃 | 亚洲av伊人久久综合密臀性色| 国产精品女同一区二区久久| 97精品久久天干天天天按摩| 亚洲伊人久久精品影院| 久久综合五月丁香久久激情| 国产精品狼人久久久久影院| 久久精品一区二区三区不卡| 亚洲精品无码久久久久久| 性欧美大战久久久久久久久| 国产精品一区二区久久精品涩爱| 久久精品三级视频| 国内精品久久久久久久涩爱| 国产激情久久久久影院小草| 久久电影网一区| 久久久久99精品成人片| 久久精品18| 久久久久久久波多野结衣高潮| 国产色综合久久无码有码|