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

            精品无码久久久久久久动漫| 91精品国产91久久久久久青草| 久久精品国产一区二区电影| 国产成人精品免费久久久久| 亚洲精品午夜国产VA久久成人| 久久综合视频网| 久久久久久午夜精品| 亚洲中文字幕无码久久综合网| 久久精品国产清自在天天线| 亚洲色大成网站www久久九| 97精品依人久久久大香线蕉97 | 国产精品久久久香蕉| 久久99这里只有精品国产| 久久婷婷是五月综合色狠狠| 亚洲婷婷国产精品电影人久久| 久久久久久国产a免费观看黄色大片 | 久久se精品一区精品二区| 日本精品久久久久中文字幕8| 国产精品成人99久久久久| 久久综合久久伊人| A级毛片无码久久精品免费| 久久99中文字幕久久| 久久男人中文字幕资源站| 一本久久a久久精品vr综合| 久久婷婷国产麻豆91天堂| 久久综合久久鬼色| 久久免费的精品国产V∧ | 国产精品禁18久久久夂久| 久久亚洲欧美日本精品| 国产免费久久精品99re丫y| 久久久亚洲欧洲日产国码二区| A级毛片无码久久精品免费| 欧美日韩久久中文字幕| AV无码久久久久不卡网站下载| 久久青青草原精品国产不卡| 久久久一本精品99久久精品66| 无码8090精品久久一区| 久久99国产精品99久久| 欧美一区二区三区久久综合| 久久亚洲高清综合| 久久久久夜夜夜精品国产|