• <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
            My graph theory is poor.I had a better understanding of toposort through this problem.
            Here is my code:
            #include<iostream>
            #include
            <string.h>
            #define maxn 107
            using namespace std;
            long n,counter,path[maxn];
            bool used[maxn],g[maxn][maxn];
            void topo(long s)
            {
                
            for(long i=1;i<=n;i++)
                    
            if(!used[i]&&g[s][i])
                        topo(i);
                used[s]
            =true;
                path[counter]
            =s;
                counter
            --;
            }
            int main()
            {
                
            /*
                freopen("data.in","r",stdin);
                freopen("data.out","w",stdout);
                //
            */
                cin
            >>n;
                memset(g,
            false,sizeof(g));
                
            for(long i=1;i<=n;i++)
                {
                    
            long t;
                    
            while(cin>>t&&t)
                        g[i][t]
            =true;
                }
                
            //  Input
                counter=n;
                memset(used,
            false,sizeof(used));
                
            for(long i=1;i<=n;i++)
                    
            if(!used[i])
                        topo(i);
                
            //  Topo Sort
                for(long i=1;i<=n;i++)
                {
                    
            if(i>=2) cout<<" ";
                    cout
            <<path[i];
                }
                cout
            <<endl;
                
            //  Output
            return 0;
            }


            posted on 2010-09-21 20:47 lee1r 閱讀(146) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:圖論
            青草久久久国产线免观| 伊人久久亚洲综合影院| AAA级久久久精品无码片| 久久99精品久久久久久| 大香网伊人久久综合网2020| 亚洲精品国产自在久久| 97久久精品无码一区二区| 久久亚洲电影| 高清免费久久午夜精品| 亚洲午夜福利精品久久| 国产精品福利一区二区久久| 久久强奷乱码老熟女网站| 久久香综合精品久久伊人| 精品久久久久久99人妻| 亚洲午夜久久久影院| 精品久久人人妻人人做精品| 久久精品国产亚洲AV无码娇色| 久久久久久久综合日本| 91精品国产91久久综合| 伊人久久精品无码av一区| 99久久国产综合精品网成人影院| 久久精品国产亚洲AV香蕉| 精品久久久久国产免费| 久久精品免费一区二区三区| 中文字幕无码免费久久| 九九热久久免费视频| 三上悠亚久久精品| 精品综合久久久久久97| 久久影视国产亚洲| 久久精品成人免费国产片小草| 国产精品久久久久影院嫩草| 香蕉久久av一区二区三区| 久久人人爽人人爽人人av东京热 | 久久毛片一区二区| 久久精品夜色噜噜亚洲A∨| 爱做久久久久久| 久久精品中文字幕久久| 久久亚洲国产中v天仙www| 久久99精品国产麻豆宅宅| 天天综合久久久网| 国产日韩久久免费影院|