博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj 1849 (浙江省赛)Attack of Panda Virus
阅读量:4607 次
发布时间:2019-06-09

本文共 1293 字,大约阅读时间需要 4 分钟。

 
/*思路 :   优先队列 bfs ,从每一天中 病毒类型最小的开始 ,所以优先队列    先 按天 排在按类型  */#include
#include
#include
#include
#include
#define N 600using namespace std;struct node{ int x; int y; int day; int ty; friend bool operator < (struct node a,struct node b) { if(a.day!=b.day) return a.day>b.day; else return a.ty>b.ty; }};int map[N][N],d[4][2]={
{0,-1},{-1,0},{0,1},{1,0}};int num[300000],n,m,sum;priority_queue
q;node p;void init(){ int i,j; while(!q.empty()) q.pop(); sum=0; memset(num,0,sizeof(num)); for(i=0;i<1500;i++) num[i]=0; for(i=0;i
0) { p.x=i; p.y=j; p.day=1; p.ty=map[i][j]; num[p.ty]++; sum++; q.push(p); } } }}bool bound(int x,int y){ if(x>=0&&y>=0&&x
=fabs(map[temp.x][temp.y])) { map[temp.x][temp.y]=p.ty; num[p.ty]++; sum++; //printf("%d\n",sum); if(sum==m*n){return ;} q.push(temp); } else { if(map[temp.x][temp.y]>max)//寻找周为最容易感染的 max=map[temp.x][temp.y]; } } } if(max!=-1111111) { p.day=-max; //若不能感染周围的 ,则等下一天 q.push(p); } }}int main(){ int t,b; while(cin>>n>>m) { init(); bfs(); cin>>t; while(t--) { scanf("%d",&b); printf("%d\n",num[b]); } }}

  

转载于:https://www.cnblogs.com/acSzz/archive/2012/04/01/2429342.html

你可能感兴趣的文章
使用 NPOI 、aspose实现execl模板公式计算
查看>>
行为型模式:中介者模式
查看>>
How to Notify Command to evaluate in mvvmlight
查看>>
33. Search in Rotated Sorted Array
查看>>
461. Hamming Distance
查看>>
Python垃圾回收机制详解
查看>>
jquery 编程的最佳实践
查看>>
MeetMe
查看>>
IP报文格式及各字段意义
查看>>
(转载)rabbitmq与springboot的安装与集成
查看>>
C2. Power Transmission (Hard Edition)(线段相交)
查看>>
STM32F0使用LL库实现SHT70通讯
查看>>
Atitit. Xss 漏洞的原理and应用xss木马
查看>>
MySQL源码 数据结构array
查看>>
(文件过多时)删除目录下全部文件
查看>>
T-SQL函数总结
查看>>
python 序列:列表
查看>>
web移动端
查看>>
pythonchallenge闯关 第13题
查看>>
linux上很方便的上传下载文件工具rz和sz使用介绍
查看>>