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

            久久精品视频免费| 久久国内免费视频| 久久精品国产亚洲AV无码娇色 | 噜噜噜色噜噜噜久久| 久久久久久曰本AV免费免费| 国产精品视频久久久| 日本高清无卡码一区二区久久| 久久婷婷国产剧情内射白浆| 久久精品国产亚洲AV无码麻豆 | 久久精品国产99国产精品导航 | 91视频国产91久久久| 一本色综合久久| 大美女久久久久久j久久| 久久精品亚洲AV久久久无码| 成人国内精品久久久久影院| 色狠狠久久综合网| 久久996热精品xxxx| 99久久精品九九亚洲精品| 国产午夜免费高清久久影院| 久久久噜噜噜久久中文字幕色伊伊| 久久久精品人妻一区二区三区四| 久久久久久极精品久久久 | 亚洲午夜久久久| 国产三级精品久久| 国产精品久久久久天天影视| 久久人爽人人爽人人片AV| 男女久久久国产一区二区三区| 久久久久亚洲精品无码网址| 久久精品18| 国产精品嫩草影院久久| 精品综合久久久久久97超人| 亚洲伊人久久精品影院| 久久精品国产亚洲AV无码娇色| 久久亚洲精品成人无码网站| 亚洲精品美女久久777777| 日日噜噜夜夜狠狠久久丁香五月| 亚洲人成无码www久久久| 久久综合色老色| 热99RE久久精品这里都是精品免费 | 久久久久久免费一区二区三区| 青青青国产成人久久111网站|