病毒侵襲的後續版本,跟之前兩道題目差不多。因為這道題要統計病毒出現的次數,在統計完乙個節點之後這個節點不能標記。這一點跟之前兩道題不同。
#include#include#include#define n 2000005
char s[n],ss[1005][55];
int mark[1005];
struct node
*root,*a[100005];
void init(node *s)
void inserttree(char *s,int k)
if(i==ln-1) p->count=k;
}return ;
}void bfs()
temp=temp->fail;
}if(temp==null) p->next[i]->fail=root;
}a[tail++]=p->next[i];}}
}return ;
}void que()
int t=s[i]-'a';
while(p->next[t]==null&&p!=root)
p=p->fail;
p=p->next[t];
if(p==null) p=root;
node *temp=p;
while(temp!=root)
}return ;
}int main()
bfs();
gets(s);
que();
for(int i=1;i<=n;i++)
}return 0;
}
hdu 3065 病毒侵襲持續中
題目大意及思路 ac自動機。include include include include include include include include include include includeusing namespace std define inf 0x3f3f3f3f define ...
HDU 3065 病毒侵襲持續中
這就更簡單了,都不用把out標記成false了 題目中的病毒都是大寫字母這個條件應該怎麼用?include include include include include include include include include include include include include ...
HDU 3065 病毒侵襲持續中
詢問每個模式串在文字傳中出現的次數。文字串中出現的字元不一定都是大寫字母,只需要在匹配的時候,對文字串進行特殊處理,將連續的大寫字母段當成合法的乙個文字串即可。然後 就是簡單的統計了。include include include include include include using name...