• <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>

            Drolca

            Apologize To Drolca
            隨筆 - 28, 文章 - 1, 評論 - 6, 引用 - 0
            數據加載中……

            pku 1386 Play on Words 歐拉回路

            #include <iostream>
            using namespace std;
            const int maxn=1005;
            const int M=28;
            int map[M][M];
            int chu[M],ru[M];
            bool vis[M];        
            int n;
            int sum;

            void dfs(int s)
            {
                vis[s]
            =true;
                sum
            ++;
                
            int i;
                
            for(i=0;i<26;i++)
                    
            if(map[s][i]&&!vis[i])
                        dfs(i);
            }


            int main()
            {
                
            int T;
                scanf(
            "%d",&T);
                
            while(T--)
                
            {
                    memset(map,
            0,sizeof(map));
                    memset(chu,
            0,sizeof(chu));
                    memset(ru,
            0,sizeof(ru));
                    memset(vis,
            0,sizeof(vis));

                    scanf(
            "%d",&n);
                    
            int i;
                    
            for(i=0;i<n;i++)
                    
            {
                        
            char word[maxn];
                        scanf(
            "%s",&word);
                        
            int len=strlen(word);
                        map[word[
            0]-'a'][word[len-1]-'a']=1;
                        chu[word[
            0]-'a']++;
                        ru[word[len
            -1]-'a']++;
                    }

                    
            int n0=0,n1=0,n2=0,n3=0;
                    
            int s=-1,e=-1;
                    
            for(i=0;i<26;i++)
                    
            {
                        
                        
            if(chu[i]==0&&ru[i]==0)
                            
            continue;
                        n0
            ++;
                        
            if((ru[i]-chu[i])==1)
                            n2
            ++;
                        
            if((chu[i]-ru[i])==0)
                            n3
            ++;
                        
            if((chu[i]-ru[i])==1)
                        
            {
                            s
            =i;
                            n1
            ++;    
                        }

                        e
            =i;
                    }

                    sum
            =0;
                    
            if(s!=-1)
                        dfs(s);
                    
            else
                        dfs(e);
                    
            if(sum!=n0)
                    
            {
                        printf(
            "The door cannot be opened.\n");
                        
            continue;
                    }

                    
            if( (n1==1&&n2==1&&n3==(n0-2)) || (n0==n3) )
                        printf(
            "Ordering is possible.\n");
                    
            else
                        printf(
            "The door cannot be opened.\n");
                }

                
            return 0;
            }

            posted on 2009-09-18 12:36 Drolca 閱讀(264) 評論(0)  編輯 收藏 引用

            久久久久久久综合狠狠综合| 日日躁夜夜躁狠狠久久AV| 久久精品免费观看| 欧美一区二区精品久久| 精品久久久久久无码中文字幕| 精品乱码久久久久久夜夜嗨| 久久久久一级精品亚洲国产成人综合AV区| 狠狠干狠狠久久| 久久婷婷人人澡人人| 东方aⅴ免费观看久久av| 91麻豆精品国产91久久久久久| 久久综合五月丁香久久激情| 久久久国产精华液| 久久综合九色综合精品| 久久久国产打桩机| 久久久久亚洲AV无码去区首| 精品久久久久久成人AV| 合区精品久久久中文字幕一区| 97久久超碰国产精品2021| 久久精品视屏| 亚洲成色999久久网站| 亚洲国产精品无码久久| 无码国内精品久久人妻麻豆按摩| 99久久人妻无码精品系列 | 青青热久久综合网伊人| 久久人人爽人人爽人人片AV东京热| 久久99精品国产99久久| 久久久久久久精品妇女99| 久久综合伊人77777| 99久久精品这里只有精品 | 一97日本道伊人久久综合影院| 久久精品免费观看| 69久久夜色精品国产69| 色欲久久久天天天综合网| 伊人久久大香线蕉无码麻豆| 久久久久国产成人精品亚洲午夜| 香港aa三级久久三级| 国产精品一区二区久久| 久久香蕉一级毛片| 久久综合九色综合久99| 国产精品热久久无码av|