摘要: http://poj.org/problem?id=2251题意:输出从S->E的最少时间,即最少步数。BFS搜索六个方向。 1 #include 2 #include 3 #include 4 using namespace std; 5 int e_x,e_y,e_z; 6 int n,row,col,vis[32][32][32]; 7 char map[32][32][32]; 8 int dir[6][3] = {{0,0,1},{0,0,-1},{0,-1,0},{0,1,0},{1,0,0},{-1,0,0}}; 9 struct node10 {11 int x;... 阅读全文
posted @ 2013-08-27 21:56 N_ll 阅读(223) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3087题意:每组3个串,前两个串长度为n,第三个串长度为2*n,依次从第二个串(s2)中取一个字符,从第一个串(s1)中取一个字符,......,直至取完,如果组成的新串(s)和第三个字符串相同则输出组数和匹配成功的次数,如果不相同,则将s串的前n个字符作为s1,后n个字符作为s2,接着匹配,如果永远匹配不成s,则输出组数和-1。思路:简单的字符串模拟,关键是判断输出-1的情况,如果一直匹配与 s不同,但与原来的strcat(s1,s2)相同,则证明无法匹配成功,因为此时字符串已经匹配了一个周期。 1 #include 2 #includ. 阅读全文
posted @ 2013-08-27 19:55 N_ll 阅读(310) 评论(0) 推荐(0)