HDU3065 病毒侵襲持續中 AC自動機

2022-05-02 20:09:12 字數 570 閱讀 3639

**:

給出$n$個模式串和乙個文字串,字符集為可見字元,找出模式串在文字串中的出現次數。

$ac$自動機的模板題,建出$trie$圖之後跳$fail$指標匹配統計數量然後按題目要求輸出即可。

ac**:

#include #include #include #include #include using namespace std;

int cnt=0;

int strid=0;

struct node

s[1005];

struct ac

}while(!que.empty())

else

trie[now][i]=trie[fail[now]][i];}}

}void query(string &str)

ac.buildfail();

cin>>tmp;

ac.query(tmp);

for(int i=1;i<=n;++i)

if(s[i].num)

cout<}

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