• <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 閱讀(94) 評論(0)  編輯 收藏 引用 所屬分類: 數據結構與算法

            久久久久18| 久久久无码一区二区三区| 99久久伊人精品综合观看| 久久精品国产精品亚洲人人| 久久久久国产一区二区三区| 丰满少妇高潮惨叫久久久| 91精品国产91久久久久久蜜臀| 久久久久国产精品三级网| 18岁日韩内射颜射午夜久久成人| 人妻精品久久无码区| 91久久福利国产成人精品| 久久亚洲精品国产亚洲老地址 | 久久不见久久见免费视频7| 伊人久久大香线焦综合四虎| 伊人久久大香线蕉无码麻豆| 成人综合伊人五月婷久久| 伊人 久久 精品| 婷婷久久综合九色综合98| 亚洲乱码精品久久久久.. | 狠狠综合久久综合中文88| 精品综合久久久久久98| 久久久91人妻无码精品蜜桃HD| 国产美女亚洲精品久久久综合| 国産精品久久久久久久| 久久精品国产99国产电影网| 亚洲精品美女久久777777| 亚洲国产综合久久天堂| 久久91这里精品国产2020| 久久超碰97人人做人人爱| 无码AV波多野结衣久久| 思思久久99热只有频精品66| 久久久精品国产Sm最大网站| 99久久精品九九亚洲精品| 91久久婷婷国产综合精品青草| 久久综合给久久狠狠97色| 久久久久亚洲AV成人网人人网站| 伊人久久大香线蕉AV一区二区| 女同久久| 亚洲中文字幕无码久久2020| 亚洲综合伊人久久综合| 久久久久无码精品国产|