题目//要仔细写的BFS,着重对#穿越的处理哦;//花了几个小时终于把这道简单的BFS给弄好了,我果然还需要增加熟练度,需要再仔细一些;//代码有点乱,但我不想改了,,,,,#include#include#include#includeusing namespace std;struct tt{ int x,y,step,floor;};int visit[20][20][2],n,m,t;char map1[20][20],map2[20][20];queue q;int xx[4]={-1,0,1,0};int yy[4]={0,1,0,-1};int bfs(){ int... Read More
posted @ 2014-01-21 22:42 laiba2004 Views(105) Comments(0) Diggs(0) Edit
题目#include#include#include#includeusing namespace std;struct tt{ int step,tem;};int visit[100010];queue q;int bfs(tt s,tt e){ tt front,temp; q.push(s); visit[s.tem]=1; while(!q.empty()) { front=q.front(); q.pop(); temp.step=front.step+1; temp.tem=front.... Read More
posted @ 2014-01-21 15:26 laiba2004 Views(247) Comments(0) Diggs(0) Edit
重点在判重的方法,嘻嘻题目#define _CRT_SECURE_NO_WARNINGS#include#includeint main(){ int i,j,len,mark[100000],num,flag; char ch[510]; while(gets(ch)) { if(strcmp("*",ch)==0)break; len=strlen(ch); flag=0; for(i=1;i<len;i++) { memset(mark,0,sizeof(mark)); ... Read More
posted @ 2014-01-21 10:07 laiba2004 Views(119) Comments(0) Diggs(0) Edit
题目//暴力的,没什么算法的,被琪琪视为傻逼的代码://照者学长的神奇幸运卡时代码,虽然能AC,但是中途wa,tle了那么多次,啥也不想说了 //学长威武,能想出sum必须要是—— __int64 —— org#define _CRT_SECURE_NO_WARNINGS#include#include#include#includeusing namespace std;struct tt{ int a,b;}c[1000010];int cmp(tt x,tt y){ if(x.a==y.a) return x.b<y.b; return x.a<y... Read More
posted @ 2014-01-18 22:45 laiba2004 Views(171) Comments(0) Diggs(0) Edit
题目#define _CRT_SECURE_NO_WARNINGS#include#include#include#includeusing namespace std;int ans[1100];int phi[30010],prime[30010],N=30010;bool is_prime[... Read More
posted @ 2014-01-18 19:47 laiba2004 Views(158) Comments(0) Diggs(0) Edit
题目//最小生成树,只是变成二维的了#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#include#includeusing namespace std;#define inf 999999999#define M 1010double mat[M][M];struct tt{ double x,y,z,r;}d[M];double prim(int n,int sta){ int mark[M],i,j; double dis[M],sum=0; for(i=0;imat[flag][j... Read More
posted @ 2014-01-17 22:06 laiba2004 Views(349) Comments(0) Diggs(0) Edit
只是坐标变成三维得了,而且要减去两边的半径而已题目//最小生成树,只是变成三维的了#define _CRT_SECURE_NO_WARNINGS#include#include#include#include#include#includeusing namespace std;#define inf 999999999#define M 110double mat[M][M];struct tt{ double x,y,z,r;}d[M];double prim(int n,int sta){ int mark[M],i,j; double dis[M],sum=0; ... Read More
posted @ 2014-01-17 21:53 laiba2004 Views(194) Comments(0) Diggs(0) Edit
题目//听说听木看懂之后,数据很水,我看看能不能水过#define _CRT_SECURE_NO_WARNINGS#include#include#include#includeusing namespace std;#define M 510#define inf 999999999int mat[M][M];int prim(int n,int sta){ int ans=0,dis[M]; int mark[M],i,j; for(i=0;idis[j]&&mark[j]==0) { flag=j; ... Read More
posted @ 2014-01-16 22:36 laiba2004 Views(136) Comments(0) Diggs(0) Edit
题目/*********题意解说——来自discuss——bysixshine**************/有卫星电台的城市之间可以任意联络。没有卫星电台的城市只能和距离小于等于D的城市联络。题目告诉你卫星电台的个数S,让你求最小的D.做最小生成树,去掉最长的S条边后,剩下最长的边就是D.也就是求最小生成树中第S+1长的边。完毕。/********************************************************///听说听木看懂之后,数据很水,果然能水过#define _CRT_SECURE_NO_WARNINGS#include#include#includ. Read More
posted @ 2014-01-16 22:23 laiba2004 Views(267) Comments(0) Diggs(0) Edit
题目/******************以下思路来自百度菜鸟的程序人生*********************/ bfs即可,可能有多个’r’,而’a’只有一个,从’a’开始搜,找到的第一个’r’即为所求 需要注意的是这题宽搜时存在障碍物,遇到’x’点是,时间+2,如果用普通的队列就并不能保证每次出队的是时间最小的元素,所以要用优先队列,第一次用优先队列,还不熟练哇 优先队列(priority_queue)的基本操作: empty();队列为空返回1 pop();出队 push();入队 top();返回队列中优先级最高的元素 size();返回队列中元素的个数/*****... Read More
posted @ 2014-01-16 19:18 laiba2004 Views(228) Comments(0) Diggs(0) Edit