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

            hdu2825

            Wireless Password

            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
            Total Submission(s): 2163    Accepted Submission(s): 596


            Problem Description
            Liyuan lives in a old apartment. One day, he suddenly found that there was a wireless network in the building. Liyuan did not know the password of the network, but he got some important information from his neighbor. He knew the password consists only of lowercase letters 'a'-'z', and he knew the length of the password. Furthermore, he got a magic word set, and his neighbor told him that the password included at least k words of the magic word set (the k words in the password possibly overlapping).

            For instance, say that you know that the password is 3 characters long, and the magic word set includes 'she' and 'he'. Then the possible password is only 'she'.

            Liyuan wants to know whether the information is enough to reduce the number of possible passwords. To answer this, please help him write a program that determines the number of possible passwords.
             

            Input
            There will be several data sets. Each data set will begin with a line with three integers n m k. n is the length of the password (1<=n<=25), m is the number of the words in the magic word set(0<=m<=10), and the number k denotes that the password included at least k words of the magic set. This is followed by m lines, each containing a word of the magic set, each word consists of between 1 and 10 lowercase letters 'a'-'z'. End of input will be marked by a line with n=0 m=0 k=0, which should not be processed.
             

            Output
            For each test case, please output the number of possible passwords MOD 20090717.
             

            Sample Input
            10 2 2 hello world 4 1 1 icpc 10 0 0 0 0 0
             

            Sample Output
            2 1 14195065
             

            Source
            2009 Multi-University Training Contest 1 - Host by TJU
             

            Recommend
            gaojie


            鴨梨巨大啊
            6個小時
            囧呆了

            code
            #include <cstdio>
            #include 
            <cstdlib>
            #include 
            <cstring>
            #include 
            <cmath>
            #include 
            <ctime>
            #include 
            <cassert>
            #include 
            <iostream>
            #include 
            <sstream>
            #include 
            <fstream>
            #include 
            <map>
            #include 
            <set>
            #include 
            <vector>
            #include 
            <queue>
            #include 
            <algorithm>
            #include 
            <iomanip>
            using namespace std;
            #define maxn 205
            #define mod 20090717
            struct node
            {
                
            int next[26];
                
            int fail,count;
                
            void init()
                {
                    memset(next,
            -1,sizeof(next));
                    count
            =0;
                    fail
            =-1;
                }
            } s[
            1000000];
            int sind;
            int head,tail,q[1000000];
            int f[30][200][1225];
            int n,m,k,kk;
            int fff[1225];
            void init1()
            {
                fff[
            0]=0;
                
            for(int i=1; i<(1<<10); i++) fff[i]=fff[i>>1]+(i&1);
            }
            void cas_init()
            {
                s[
            0].init();
                sind
            =1;
            }
            void ins(char str[],int off)
            {
                
            int len,i,j,ind;
                ind
            =0;
                len
            =strlen(str);
                
            for(i=0; i<len; i++)
                {
                    j
            =str[i]-'a';
                    
            if(s[ind].next[j]==-1)
                    {
                        s[sind].init();
                        s[ind].next[j]
            =sind++;
                    }
                    ind
            =s[ind].next[j];
                }
                s[ind].count
            = s[ind].count|(1<<off);
            }
            void make_fail()
            {
                
            int p,i,son,u;
                head
            =0;
                tail
            =1;
                q[tail]
            =0;
                
            while(head<tail)
                {
                    u
            =q[++head];
                    
            for(i=0; i<26; i++)
                    {
                        
            if(s[u].next[i]!=-1)
                        {
                            p
            =s[u].fail;
                            son
            =s[u].next[i];
                            
            while(p!=-1&&s[p].next[i]==-1) p=s[p].fail;
                            
            if(u==0) s[son].fail=0;
                            
            else s[son].fail=s[p].next[i];
                            s[son].count
            =s[son].count| s[s[son].fail].count;
                            q[
            ++tail]=son;
                        }
                        
            else
                        {
                            p
            =s[u].fail;
                            
            while(p!=-1&&s[p].next[i]==-1) p=s[p].fail;
                            
            if(u==0) s[u].next[i]=0;
                            
            else s[u].next[i]=s[p].next[i];
                        }

                    }
                }
            }
            void solve()
            {
                
            int i,j,tk,l,son;
                kk
            =1<<m;
                
            for(i=0; i<=n; i++)
                    
            for(j=0; j<=sind; j++)
                        
            for(tk=0; tk<=kk; tk++)
                            f[i][j][tk]
            =0;
                f[
            0][0][0]=1;

                
            for(i=0; i<n; i++)
                {
                    
            for(j=0; j<sind; j++)
                    {
                        
            for(tk=0; tk<kk; tk++)
                        {
                            
            if(f[i][j][tk]==0continue;
                            
            for(l=0; l<26; l++)
                            {
                                son
            =s[j].next[l];
                                f[i
            +1][son][tk|s[son].count]=f[i+1][son][tk|s[son].count]+f[i][j][tk];
                                f[i
            +1][son][tk|s[son].count]=f[i+1][son][tk|s[son].count]%mod;
                            }
                        }
                    }
                }
                
            int ans;
                ans
            =0;
                
            for(i=0; i<sind; i++)
                    
            for(j=0; j<kk; j++)
                        
            if(fff[j]>=k)
                        {
                            ans
            =ans+f[n][i][j];
                            ans
            =ans%mod;
                        }
                printf(
            "%d\n",ans);
            }
            int main()
            {
                
            char str[105];
                init1();
                
            while(scanf("%d%d%d",&n,&m,&k)!=EOF)
                {
                    
            if(n==0&&m==0&&k==0break;
                    cas_init();
                    
            for(int i=0; i<m; i++)
                    {
                        scanf(
            "%s",str);
                        ins(str,i);
                    }
                    make_fail();
                    solve();
                }
                
            return 0;
            }

            posted on 2012-08-03 21:42 jh818012 閱讀(166) 評論(0)  編輯 收藏 引用

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評論內容較長,點擊標題查看
            • --王私江
            欧美精品丝袜久久久中文字幕 | 国产成人久久777777| 亚洲国产精品18久久久久久| 亚洲va国产va天堂va久久| 久久精品国产亚洲AV高清热 | 亚洲国产成人久久综合野外| 精品国产乱码久久久久软件| 久久免费的精品国产V∧| 国产精品久久久久久久午夜片 | 久久天天婷婷五月俺也去| 日韩人妻无码精品久久久不卡| 国产99久久精品一区二区| 久久久久亚洲AV成人网人人网站 | 97精品伊人久久久大香线蕉| 日韩亚洲国产综合久久久| 无码人妻精品一区二区三区久久久| 一级做a爱片久久毛片| 亚洲精品无码久久久久久| 久久99精品久久久久久9蜜桃| 久久香综合精品久久伊人| 久久久久亚洲精品男人的天堂| 国内精品久久久久久野外| 人妻久久久一区二区三区| 日本WV一本一道久久香蕉| 久久人人爽人人精品视频| 国产 亚洲 欧美 另类 久久| 国内精品伊人久久久久av一坑| 久久99国产精品久久久 | 51久久夜色精品国产| 久久久久人妻一区精品色| 亚洲精品无码久久久| 91精品日韩人妻无码久久不卡| 99久久精品国内| 久久人爽人人爽人人片AV| 伊人久久大香线蕉av不卡 | 久久人人爽人人澡人人高潮AV| 国产V亚洲V天堂无码久久久| 精品国产乱码久久久久久1区2区| 综合人妻久久一区二区精品| 囯产极品美女高潮无套久久久 | 国产情侣久久久久aⅴ免费|