摘要: 题意:给出m个模式和一个文本,求各种模式的出现次数比较裸的AC自动机,成功匹配就计数就是了..View Code 1 //Accepted 3065 281MS 13724K 2340 B C++ 2 3 #include <iostream> 4 #include <cstring> 5 #include <cstdio> 6 #include <cmath> 7 #include <algorithm> 8 using namespace std; 9 const int inf=1<<28; 10 const int 阅读全文
posted @ 2012-08-22 20:34 Wheat″ 阅读(143) 评论(0) 推荐(0)
摘要: 题目大意:找出匹配串在父串中出现的次数View Code 1 #include <iostream> 2 #include <string.h> 3 const int MAXN = 1000012; 4 char a[MAXN],b[MAXN];//a主串 b匹配串 5 void get_next(char *pstr,int *next) 6 { 7 int i=0; 8 *next=-1; 9 int j=-1;10 while(*(pstr+i)!='\0')11 {12 if(j==-1||*(pstr+i)==*(pstr+... 阅读全文
posted @ 2012-08-22 20:19 Wheat″ 阅读(120) 评论(0) 推荐(0)
摘要: 题意:给出m个模式和一个文本,求各种模式的出现次数比较裸的AC自动机,成功匹配就计数就是了..View Code 1 //Accepted 2896 156MS 23516K 2412 B C++ 2 3 #include <iostream> 4 #include <cstring> 5 #include <cstdio> 6 #include <cmath> 7 #include <algorithm> 8 using namespace std; 9 const int inf=1<<28; 10 const int 阅读全文
posted @ 2012-08-22 20:17 Wheat″ 阅读(249) 评论(0) 推荐(0)
摘要: 递归+两个栈,一个存符号一个存数字,判断符号的优先级 +,- < *,/ < )in(111+999)/20+111(111+333*3)/(20+80)-(111+999)/20+111(1+(2+(3+4*5)-10000out166.50000066.6000000-9974.000000View Code 1 #include <string> 2 #include <fstream> 3 #include <iostream> 4 using namespace std; 5 6 7 bool valid = true, Found = 阅读全文
posted @ 2012-08-20 20:43 Wheat″ 阅读(156) 评论(0) 推荐(0)
摘要: 一道很好的字典树题目,用每组第二个单词构造字典树,最后一个节点存第一个单词,其他节点存ch,接着对每个输入进行查询View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #define M 26 5 using namespace std; 6 int ii; 7 struct Tree{ 8 Tree* next[M]; 9 char val[100];10 Tree()11 {12 for(ii=0;ii<M;ii++)13 ... 阅读全文
posted @ 2012-08-20 09:07 Wheat″ 阅读(132) 评论(0) 推荐(0)
摘要: View Code 1 import java.io.IOException; 2 3 4 public class IP1 { 5 public static void main(String[] args) { 6 String str="netsh interface ipv4 set address name=本地连接 source=static addr=172.16.101.145 mask=255.255.255.0 gateway=172.16.101.254 gwmetric=0"; 7 8 try { 9 ... 阅读全文
posted @ 2012-08-19 17:12 Wheat″ 阅读(299) 评论(0) 推荐(0)
摘要: 先把字符串翻转过来,再通过sscanf函数的处理,获取A,B,C的值,再做比较,需要注意的是当输入 0+0=0 输出True 然后结束View Code 1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 char data[30]; 5 int main() 6 { 7 while (true) 8 { 9 cin >> data;10 if (strcmp(data, "0+0=0") == 0)11 {12 cout... 阅读全文
posted @ 2012-08-19 16:50 Wheat″ 阅读(219) 评论(0) 推荐(0)
摘要: 简单的字符串操作,用二维数组回旋处理输入的字符串,然后竖着输出二维字符数组toioynnkpheleaigshareconhtomesnlewx输出:| t o i o y ->|| h p k n n <-| e l e a i ->|| r a h s g <-| | e c o n h ->|| s e m o t <-|∨ n l e w x ->theresnoplacelikehomeonasnowynightxView Code 1 #include <stdio.h> 2 #include <string.h> 阅读全文
posted @ 2012-08-19 15:23 Wheat″ 阅读(140) 评论(0) 推荐(0)
摘要: 简单的广搜题目,单广能过,可以拿这题练习双广单广:View Code 1 #include <stdio.h> 2 #include <string.h> 3 4 int n; 5 int x1,y1,x2,y2; 6 int array[2][8] = {{-1, -1, -2, -2, 2, 2, 1, 1},{-2, 2, 1, -1, 1, -1, 2, -2}};//表示马跳的8个方向 7 int q[100000][3]; 8 bool h[310][310]; 9 void bfs()10 {11 int i,sd,ed;12 int x,y,a,b,c; 阅读全文
posted @ 2012-08-18 17:23 Wheat″ 阅读(151) 评论(0) 推荐(0)
摘要: 题目意思:骑士游历的问题咯,单向广搜能过,也可以拿来练习双向广搜咯,附双向广搜代码View Code 1 #include <iostream> 2 #include <queue> 3 #include <cstdio> 4 using namespace std; 5 #define MAX 10 6 struct Status // 结构 7 { 8 int x,y; //位置 9 int vis; 10 }; 11 int visited[MAX][MAX];//标记数组 12 int dir[8][2]={{-2, -1}, {-2, 1... 阅读全文
posted @ 2012-08-18 17:13 Wheat″ 阅读(152) 评论(0) 推荐(1)