HDU2896 病毒侵襲 AC自動機

2021-07-26 18:22:09 字數 861 閱讀 3536

記錄乙個菜逼的成長。。

題目鏈結

題目大意:

n個字串,m個字串,問m個字串裡每乙個都包含了哪幾種n個字串裡的。

跟上題類似,只不過這題有128個分支,把cnt陣列用來記錄n個字串的編號,輸出用優先佇列維護。

#include 

using

namespace

std;

#define cl(a,b) memset(a,b,sizeof(a))

typedef

long

long ll;

const

int inf = 0x3f3f3f3f;

priority_queue,greater >q;

struct trie

void init()

void insert(char buf)

cnt[now] = id++;

}void build()

while( !q.empty() )}}

void query(char buf)}}

};const

int maxn = 10000 + 10;

char s[510][210],web[maxn];

trie ac;

int main()

ac.build();

int m,tot = 0,id = 0;scanf("%d",&m);

while(m--)

puts("");

}printf("total: %d\n",tot);

}return

0;}

hdu 2896 病毒侵襲 AC自動機

hdu 2896 題目大意 給出n個模式串,最後給出m個主串 問有主串出現過哪些模式串,最後輸出哪些主串能匹配模式串 解題思路 ac自動機建立字典樹的用w值標記第幾個模式串 定義k值,匹配時若字典樹中的某個結點不等於k且w不為0則記錄該點 有多個主串需要匹配,所以不需要改變w的值,但可以判斷k的值 ...

hdu 2896 病毒侵襲 ac自動機

include include include using namespace std define maxnode 100100 define sigma size 135 int ch maxnode sigma size int f maxnode fail函式 int val maxnode...

AC自動機 病毒侵襲 hdu2896

和hdu2222題相似的水題 1 連著re了好多發,沒想明白,看了一下網上題解才知道,輸入的不一定都是字母,所以next要開100!include include int tot char str 10005 int t int time 100 struct trie queue 100005 s...