• <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, 評(píng)論 - 6, 引用 - 0
            數(shù)據(jù)加載中……

            pku 2724 Purifying Machine

             

            #include <iostream>
            using namespace std;
            const int maxn=1025;
            const int maxm=100000;

            struct gtype
            {
                
            int x,y,next;
            }
            ;
            gtype g[maxm];
            int first[maxn];
            int link[maxn];
            bool used[maxn];
            int f2[11]={1,2,4,8,16,32,64,128,256,512,1024};
            bool in[1025];
            int cheese[1025];
            int n,m,tot;
            int i,j,all;

            void add(int x,int y)
            {
                tot
            ++;
                g[tot].x
            =x;g[tot].y=y;
                g[tot].next
            =first[x];
                first[x]
            =tot;
            }


            bool find(int s)
            {
                
            int temp=first[s];
                
            while(temp!=-1)
                
            {
                    
            int e=g[temp].y;
                    
            if(!used[e])
                    
            {
                        used[e]
            =true;
                        
            if(link[e]==0||find(link[e]))
                        
            {
                            link[e]
            =s;
                            
            return 1;
                        }
                
                    }

                    temp
            =g[temp].next;
                }

                
            return 0;
            }


            int match()
            {
                
            int sum=0;
                
            for(i=0;i<all;i++)
                
            {
                    memset(used,
            0,sizeof(used));
                    sum
            +=find(i);
                }

                
            return sum;
            }


            bool check(int a,int b)
            {
                
            int t=cheese[a]^cheese[b];
                
            return t&&(t&(t-1))==0;
            }


            int main()
            {
                
            while(cin>>n>>m)
                
            {
                    
            if(n==0&&m==0break;
                    memset(first,
            -1,sizeof(first));
                    memset(link,
            0,sizeof(link));
                    
            char s;
                    
            for(i=0;i<m;i++)
                    
            {    
                        
            int flag=-1;
                        
            int t=0;
                        
            for(j=0;j<n;j++)
                        
            {
                            cin
            >>s;
                            
            if(s=='*')
                            
            {
                                flag
            =j;
                                
            continue;
                            }

                            t
            +=(s-'0')*f2[j];
                        }

                        
            in[t]=true;
                        
            if(flag!=-1)
                            
            in[t+f2[flag]]=true;
                    }

                    all
            =0;
                    
            for(i=0;i<(1<<n);i++)
                        
            if(in[i])
                            cheese[all
            ++]=i;
                    
            for(i=0;i<all;i++)
                        
            for(j=0;j<all;j++)
                        
            {
                            
            if(i==j) continue;
                            
            if(check(i,j)) 
                                add(i,j);
                        }

                    
            int ans=all-match()/2;
                    cout
            <<ans<<endl;
                }

                
            return 0;
            }

            posted on 2009-08-16 18:58 Drolca 閱讀(193) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            亚洲αv久久久噜噜噜噜噜| 久久99国产综合精品女同| 久久AⅤ人妻少妇嫩草影院| 国产精品美女久久久久AV福利| 精品乱码久久久久久夜夜嗨| 亚洲欧洲精品成人久久曰影片 | 久久久99精品成人片中文字幕| 狠狠色丁香婷婷久久综合五月| 久久精品一本到99热免费| 狠狠色综合网站久久久久久久| 久久精品久久久久观看99水蜜桃| 久久精品国产99国产精偷| 97精品伊人久久久大香线蕉| 国产精品免费看久久久香蕉| 精品久久久无码21p发布| 99国内精品久久久久久久| 日韩久久久久中文字幕人妻| 国产成人久久AV免费| 一本一本久久a久久综合精品蜜桃| 超级碰久久免费公开视频| 久久久久亚洲精品无码蜜桃 | 久久久久久无码国产精品中文字幕 | 国产精品丝袜久久久久久不卡| 无码AV中文字幕久久专区| 欧美午夜A∨大片久久| 99久久精品国产毛片| 久久精品国产91久久麻豆自制| 亚洲AV无码久久精品蜜桃| 亚洲国产成人久久一区久久| 青青草国产精品久久| 精品久久久久久中文字幕人妻最新| 三级三级久久三级久久 | 人妻久久久一区二区三区| 久久99热这里只有精品66| 三级韩国一区久久二区综合| 精品久久久久久久中文字幕 | 久久免费线看线看| 热99re久久国超精品首页| 久久91亚洲人成电影网站| 久久久久四虎国产精品| 精品久久国产一区二区三区香蕉 |