解析:用end陣列標記病毒編號,用used陣列記錄各個病毒出現的次數,最後對應輸出即可。
ac**:
#include using namespace std;
const int maxn = 1002;
const int max_word = 52;
const int max_text = 2000002;
const int sigma_size = 128;
char buf[max_text], vir[maxn][max_word]; //vir儲存對應病毒序列
struct trie
void init()
void insert(char buf, int id)
end[now] = id; //標記病毒編號
}void build()
}while(!q.empty())}}
}int used[maxn]; //計數
int query(char buf, int n)
temp = fail[temp];}}
if(flag)
}void debug(){
for(int i = 0; i < l; i++){
printf("id = %3d, fail = %3d, end = %3d, chi = [", i, fail[i], end[i]);
for(int j = 0; j
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...