标签:std log 状压 ems sim fine bottom search 算法
地址:
题目:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 763 Accepted Submission(s): 171
思路:
shiftand算法,不会的先百度吧。
因为模式串比较长,所以bitset状压一下。
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 #define MP make_pair 6 #define PB push_back 7 typedef long long LL; 8 typedef pair<int,int> PII; 9 const double eps=1e-8; 10 const double pi=acos(-1.0); 11 const int K=1e6+7; 12 const int mod=1e9+7; 13 14 int getidx(char c) 15 { 16 if(‘0‘<=c&&c<=‘9‘) return c-‘0‘; 17 if(‘a‘<=c&&c<=‘z‘) return c-‘a‘+11; 18 if(‘A‘<=c&&c<=‘Z‘) return c-‘A‘+37; 19 return 63; 20 } 21 22 char sa[2000007],sb[300]; 23 bitset<500>bt[65],d; 24 int n; 25 int main(void) 26 { 27 //freopen("in.acm","r",stdin); 28 while(gets(sa)) 29 { 30 memset(bt,0,sizeof bt); 31 scanf("%d",&n); 32 for(int i=0,len;i<n;i++) 33 { 34 scanf("%d%s",&len,sb); 35 for(int j=0;j<len;j++) bt[getidx(sb[j])][i]=1; 36 } 37 int len=strlen(sa),ff=0; 38 d.reset(); 39 for(int i=0;i<len;i++) 40 { 41 d <<=1; 42 d[0]=1; 43 d &= bt[getidx(sa[i])]; 44 if(d[n-1]) printf("%d\n",i-n+2),ff=1; 45 } 46 getchar(); 47 if(!ff) printf("NULL\n"); 48 } 49 return 0; 50 }
标签:std log 状压 ems sim fine bottom search 算法
原文地址:http://www.cnblogs.com/weeping/p/7608647.html