• <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>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            題目大意:給出無向圖每個頂點的度,試圖構建一個符合條件的圖。
            見Havel-Hakimi定理。
            以下是我的代碼:
            #include<algorithm>
            #include
            <cstdio>
            #include
            <cstring>
            using namespace std;
            const int kMaxn(17);

            struct Type
            {
                
            int num,degree;
            };
            bool operator<(const Type &a,const Type &b)
            {
                
            return (a.degree>b.degree || (a.degree==b.degree && a.num<b.num));
            }

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

                
            int T;
                scanf(
            "%d",&T);
                
            for(int case_num=1;case_num<=T;case_num++)
                {
                    
            int n;
                    Type r[kMaxn];
                    scanf(
            "%d",&n);
                    
            for(int i=1;i<=n;i++)
                    {
                        r[i].num
            =i;
                        scanf(
            "%d",&r[i].degree);
                    }

                    
            bool success(true);
                    
            int g[kMaxn][kMaxn];
                    memset(g,
            0,kMaxn*kMaxn*sizeof(int));
                    
            for(int i=1;i<=n;i++)
                    {
                        sort(r
            +i,r+n+1);
                        
            if(r[i].degree<0)
                        {
                            success
            =false;
                            
            break;
                        }
                        
            for(int j=i+1;j<=&& j<=i+r[i].degree;j++)
                        {
                            g[r[i].num][r[j].num]
            =g[r[j].num][r[i].num]=1;
                            r[j].degree
            --;
                        }
                    }

                    
            if(case_num!=1)
                        printf(
            "\n");
                    
            if(!success)
                        printf(
            "NO\n");
                    
            else
                    {
                        printf(
            "YES\n");
                        
            for(int i=1;i<=n;i++)
                        {
                            
            for(int j=1;j<=n;j++)
                            {
                                
            if(j!=1)
                                    printf(
            " ");
                                printf(
            "%d",g[i][j]);
                            }
                            printf(
            "\n");
                        }
                    }
                }

                
            return 0;
            }
            posted on 2011-05-26 13:10 lee1r 閱讀(176) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:圖論
            久久夜色精品国产www| 99精品国产99久久久久久97 | 亚洲精品蜜桃久久久久久| 久久精品国产亚洲AV影院| 欧美熟妇另类久久久久久不卡| 久久精品成人国产午夜| 亚洲精品99久久久久中文字幕| 色欲综合久久中文字幕网| 国产精品九九久久免费视频| 久久精品国产99久久久古代| av无码久久久久不卡免费网站 | 国产aⅴ激情无码久久| 精品久久久久久亚洲| 中文字幕无码久久精品青草| 99久久免费国产精品热| 久久中文字幕人妻熟av女| 国产成人久久精品二区三区| 亚洲乱码精品久久久久.. | 91精品国产91久久综合| 欧美黑人激情性久久| 精品国产综合区久久久久久| 久久婷婷国产综合精品| 久久久久久久女国产乱让韩 | 欧美亚洲国产精品久久高清| 国产精品永久久久久久久久久| 人妻精品久久久久中文字幕一冢本 | 久久久精品国产亚洲成人满18免费网站| 无码人妻久久一区二区三区免费| 久久青青国产| 久久乐国产精品亚洲综合| 久久99国产精品久久| 国产精品免费看久久久| 久久午夜伦鲁片免费无码| 色综合久久综合中文综合网 | 999久久久国产精品| 91精品国产91久久| 国产69精品久久久久99| 99国内精品久久久久久久| 久久93精品国产91久久综合| 久久人人爽人爽人人爽av| 久久午夜免费视频|