一开始做这道题没什么头绪,那时只会写Trie,ac自动机不怎么懂。后来在discuss里看到要用AC自动机做。先把要查询的字符串添加进Trie图里,建完自动机后再从矩形四周八个方向依次查询,结果放在数组里。 1 #include<cstdio> 2 #include<string.h> 3 #include<iostream> 4 #include<queue> 5 using namespace std; 6 const int maxn=1001; 7 char g[maxn][maxn],T[maxn][maxn],str[maxn]; 8 Read More
posted @ 2013-05-22 20:55 longlongago Views(123) Comments(0) Diggs(0) Edit