随笔分类 - 图论--BFS
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1180这题交了7次 悲剧了 前几次 因为把+行想成是左右走了 一直WA 后来看出来了 又把走过的楼梯给标记了 这里的楼梯不能标记因为可以在原地等着楼梯转变 加的时间有可能是2 这样普通队列满足不了最少的先搜 就用优先队列了View Code 1 #include<stdio.h> 2 #include<string.h> 3 typedef struct node 4 { 5 int x,y,num; 6 }st; 7 int f[22][22]; 8 char c[22][22];
阅读全文
摘要:View Code 1 #include<stdio.h> 2 #include<string.h> 3 typedef struct que 4 { 5 int x,y; 6 long num; 7 }st; 8 st q[10001]; 9 char str[1001][1001]; 10 int f[1001][1001]; 11 int p,d; 12 void inque(int a,int b) 13 { 14 d++; 15 if(d>10000) 16 d = d%10000; 17 q[d].x = a; 1...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1242刚开始由于 没标记已走过的 导致RE TLE 纠结了好久 同样纠结为什么正着搜就WAView Code 1 #include <stdio.h> 2 #include<string.h> 3 int n, m,p = 0,q = 0; 4 char c[201][201]; 5 typedef struct queue 6 { 7 int num, x, y; 8 }st; 9 st Q[100001];10 void inque(int a, int b)11 {12 q++;
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2139BFS 借助队列 将节点的邻接点依次存入队中View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include<string.h> 4 int k[1001][1001],f[1001],n,m,p = 0,w; 5 typedef struct node 6 { 7 int num,y; 8 }st; 9 st q[1001];10 void
阅读全文

浙公网安备 33010602011771号