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

            巢穴

            about:blank

            P2513

            trie+并查集+歐拉回路
            有空數據..其實沒影響..但是討論里有個人說空數據輸出Impossible...其實應該Possible...
            這個人太邪惡了..
            另外用數組寫tire,re了不下5次..
            最后改成了動態的..
            1000+ms..還是挺慢的..

            #include <iostream>
            #include 
            <stdio.h>
            #include 
            <string>
            using namespace std;
            struct node
            {
             node 
            *s[26];
             
            int count;
             
            int pos;
             node()
             
            {
              count
            =0;
              pos
            =0;
              
            for(int i=0;i<26;i++)
               s[i]
            =NULL;
             }

             
            }
            *root;
            int f[500010],o[500010];
            int len=0,l=0;
            char st1[11];
            char st2[11];
            int insert(char *ch)
            {
                 
            int ts=0;
                 node 
            *p=root;
                 
            for (int i=0;i<strlen(ch);i++)
                 
            {
                     
            if ((p->s[ch[i]-'a'])==NULL)
                     
            {
                      p
            ->s[ch[i]-'a']=new node();
                     }

                     p
            =p->s[ch[i]-'a'];
                 }

                 
            if (p->count==0)
                 
            {
                  len
            ++;
                  p
            ->count=1;
                  p
            ->pos=len;
                  ts
            =len;
                  
            return ts;
                 }

                 
            else
                 
            {
                  ts
            =p->pos;
                  
            return ts;
                 }

                 
                 
            }

            int getfather(int x)
            {
             
            if (f[x]==x) return x;
             f[x]
            =getfather(f[x]);
             
            return f[x];
            }

            int main()
            {
                
                
            for (int i=0;i<500010;i++)
                 
            {f[i]=i;o[i]=0;}
                root
            =new node();
                
            int u=0;
                
            while(scanf ("%s %s", st1, st2) != EOF)
                
            {
                 u
            ++;
                 
            int x=insert(st1);
                 
            int y=insert(st2);
                 
            int fx=getfather(x);
                 
            int fy=getfather(y);
                 o[x]
            ++;
                 o[y]
            ++;
                 
            if (fx!=fy) f[fy]=fx;
                
            // if (u==5) break;
                }

                
                
            int itn=0;
                
            for (int i=1;i<=len;i++)
                 
            if (getfather(i)==i) itn++;
                
            int odd=0;
                
            for (int i=1;i<=len;i++)
                 
            if (o[i]%2) odd++;
                
                
            if (len==0)
                
            {
                 cout
            <<"Possible"<<endl;
                 exit(
            0);
                }

                
            if (itn==1&&(odd==2||odd==0)) 
                
            {
                 cout
            <<"Possible"<<endl;
                }

                
            else
                
            {
                 cout
            <<"Impossible"<<endl;
                }

               
            // system("pause");
                 
                
            return 0;
            }

            posted on 2009-11-03 16:59 Vincent 閱讀(96) 評論(0)  編輯 收藏 引用 所屬分類: 數據結構與算法

            久久精品国产精品亚洲| 久久久免费观成人影院| 精品人妻久久久久久888| 天天做夜夜做久久做狠狠| 99国产欧美久久久精品蜜芽 | 国产精品九九久久免费视频 | 久久久久九国产精品| 最新久久免费视频| 国产国产成人久久精品| 日韩精品久久久久久久电影| 色综合久久无码五十路人妻| 久久精品国产91久久综合麻豆自制| 亚洲AV无码久久| 精产国品久久一二三产区区别| 久久人做人爽一区二区三区| 亚洲性久久久影院| 亚洲综合伊人久久综合| 精品午夜久久福利大片| 久久99热精品| 激情综合色综合久久综合| 狠狠色丁香久久婷婷综合蜜芽五月| 色偷偷88欧美精品久久久| 久久国产精品无| 国产精久久一区二区三区| 伊人色综合久久天天人手人婷| 国产精品久久精品| 亚洲精品乱码久久久久久| 草草久久久无码国产专区| 国产产无码乱码精品久久鸭 | 77777亚洲午夜久久多人| 久久国产成人精品国产成人亚洲| 天天爽天天狠久久久综合麻豆| 亚洲国产成人久久综合野外| 久久国产视屏| AA级片免费看视频久久| 久久国产色av免费看| 精品国际久久久久999波多野| 九九久久精品国产| 久久婷婷成人综合色综合| 亚洲人成无码久久电影网站| 国产叼嘿久久精品久久|