• <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>
            數(shù)據(jù)加載中……

            URAL 1022 Genealogical tree

            拓撲排序是最直接的算法.
             1 /* 拓撲排序 */
             2 
             3 #include<iostream>
             4 #include<vector>
             5 using namespace std;
             6 const int MAXN=120;
             7 vector<int> adj[MAXN];
             8 
             9 int into[MAXN];
            10 
            11 int main()
            12 {
            13   //freopen("data.in","r",stdin);
            14   //freopen("data.out","w",stdout);
            15   int n;
            16   memset(into,0,sizeof(into));
            17   cin >> n;
            18   for (int i=1;i<=n;++i)
            19     {
            20       int x;
            21       cin >> x;
            22       while (x!=0
            23     {
            24       adj[i].push_back(x);
            25       ++into[x];
            26       cin >> x;
            27     }
            28     }
            29  //for (int i=1;i<=n;++i) cout << into[i] << ' '; cout << endl;
            30   bool everp=0;
            31   for (int k=0;k<n;++k)
            32     {
            33       int i=1;
            34       for (;i<=n;i++if (!into[i]) break;
            35       (everp) ? cout << ' ' << i : cout << i;
            36       everp=1;
            37       --into[i];
            38       for (int j=0;j<adj[i].size();++j) --into[ adj[i][j] ];
            39     }
            40   cout << endl;
            41   return 0;
            42 }
            43 


            posted on 2009-07-21 17:14 Chen Jiecao 閱讀(192) 評論(0)  編輯 收藏 引用 所屬分類: URAL

            久久久久久久综合综合狠狠| 久久精品国产91久久综合麻豆自制| 99久久精品费精品国产一区二区| 韩国无遮挡三级久久| 91精品国产91久久久久久蜜臀| 国产精品内射久久久久欢欢| 久久国产AVJUST麻豆| 精品综合久久久久久888蜜芽| 久久精品国产精品青草app| 久久最新免费视频| 久久久久亚洲AV无码专区首JN | 99久久无码一区人妻| 国产午夜精品理论片久久| 日韩影院久久| 一本伊大人香蕉久久网手机| 狠狠综合久久综合88亚洲| 91精品婷婷国产综合久久| 久久天天躁狠狠躁夜夜不卡| 国产精品成人99久久久久 | 一本久久a久久精品vr综合| 欧美一区二区精品久久| 青青草原综合久久大伊人| 国产V亚洲V天堂无码久久久 | 亚洲中文字幕久久精品无码喷水| 久久国产精品-久久精品| 色欲av伊人久久大香线蕉影院| 久久精品视屏| 久久精品国产亚洲Aⅴ蜜臀色欲| 久久久亚洲欧洲日产国码aⅴ| 久久精品卫校国产小美女| 国产精品久久久久乳精品爆| 久久超乳爆乳中文字幕| 久久天天躁狠狠躁夜夜躁2O2O| 久久午夜福利无码1000合集| 日韩久久无码免费毛片软件| 亚洲一本综合久久| 亚洲国产精品热久久| 国产69精品久久久久99尤物| 人人狠狠综合久久亚洲88| 久久综合狠狠综合久久激情 | 久久91综合国产91久久精品|