题目链接:

  http://codeforces.com/gym/100825

题目大意:

  N个点M条无向边,(N<=100,M<=N(N-1)/2),起始感染源S,时间T(T<10),每个感染源会在1个单位时间内给与自己相连的所有点传递与自身病毒数相等的病毒,然后自己的病毒数归零,被感染点在1个单位时间之后会收到病毒。

  求T时刻这张图上的总病毒数。(初始时刻为0,S带有1个病毒)

题目思路:

  【宽搜】

  这题因为T很小,N也很小所以可以暴力宽搜,把图按时间奇偶分成两层,每次病毒都从一层中的感染源传递到另一层中与感染源相邻的点。

  最后统计答案即可。

 //
//by coolxxx
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define mem(a,b) memset(a,b,sizeof(a))
#define eps (1e-10)
#define J 10000
#define mod 1000000007
#define MAX 0x7f7f7f7f
#define PI 3.14159265358979323
#define N 104
#define M 10004
using namespace std;
typedef long long LL;
double anss;
LL aans;
int cas,cass;
int n,m,lll,ans;
int s,t;
int last[N];
LL d[][N];
int q[][N];
bool u[][N];
struct edge
{
int next,to;
}a[M];
void add(int x,int y)
{
a[++lll].to=y;
a[lll].next=last[x];
last[x]=lll;
}
void spfa()
{
int i,now,to,k=,tt,l[],r[];
mem(d,);mem(u,);
l[]=l[]=r[]=r[]=;
for(i=last[s];i;i=a[i].next)
{
q[][++r[]]=a[i].to;
d[][a[i].to]=;
}
for(tt=;tt<t-;tt++)
{
k=tt&;
while(l[k]<r[k])
{
now=q[k][++l[k]];
for(i=last[now];i;i=a[i].next)
{
to=a[i].to;
d[-k][to]+=d[k][now];
if(!u[-k][to])
{
u[-k][to]=;
q[-k][++r[-k]]=to;
}
}
}
l[k]=r[k]=;
mem(d[k],);mem(u[k],);
}
for(i=;i<=n;i++)
aans+=d[-k][i];
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,k;
int x,y,z;
// init();
// for(scanf("%d",&cass);cass;cass--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s))
while(~scanf("%d",&n))
{
aans=;lll=;mem(last,);
scanf("%d%d%d",&m,&s,&t);
s++;
for(i=;i<=m;i++)
{
scanf("%d%d",&x,&y);
x++,y++;
add(x,y),add(y,x);
}
if(t==){puts("");continue;}
spfa();
printf("%I64d\n",aans);
}
return ;
}
/*
// //
*/

【宽搜】ECNA 2015 E Squawk Virus (Codeforces GYM 100825)的更多相关文章

  1. 【最大流】ECNA 2015 F Transportation Delegation (Codeforces GYM 100825)

    题目链接: http://codeforces.com/gym/100825 题目大意: N(N<=600)个点,每个点有个名字Si,R(R<=200)个生产商在R个点上,F(F<= ...

  2. 【宽搜】BAPC2014 J Jury Jeopardy (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  3. 【宽搜】ECNA 2015 D Rings (Codeforces GYM 100825)

    题目链接: http://codeforces.com/gym/100825 题目大意: 给你一张N*N(N<=100)的图表示一个树桩,'T'为年轮,'.'为空,求每个'T'属于哪一圈年轮,空 ...

  4. 【模拟】ECNA 2015 I What's on the Grille? (Codeforces GYM 100825)

    题目链接: http://codeforces.com/gym/100825 题目大意: 栅栏密码.给定N(N<=10),密钥为一个N*N的矩阵,'.'代表空格可以看到,'X'代表被遮挡,还有密 ...

  5. codeforces gym 100825 D Rings

    这题果然就是个暴力题.... 看每个T的四个方向,有'.',或者在边界上就填1 不然就填四个方向上最小的那个数再加1 然而写wa了几发,有点蠢... #include <bits/stdc++. ...

  6. poj1399 hoj1037 Direct Visibility 题解 (宽搜)

    http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...

  7. 利用深搜和宽搜两种算法解决TreeView控件加载文件的问题。

    利用TreeView控件加载文件,必须遍历处所有的文件和文件夹. 深搜算法用到了递归. using System; using System.Collections.Generic; using Sy ...

  8. POJ1426 Find The Multiple (宽搜思想)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24768   Accepted: 102 ...

  9. Colorado Potato Beetle(CF的某道) & 鬼畜宽搜

    题意: 一个人在一张大图上走,给你路径与起点,求他走出的矩形面积并.(大概这个意思自行百度标题... SOL: 与其说这是一道图论题不如说是一道生动活泼的STL-vector教学.... 离散化宽搜, ...

随机推荐

  1. one way WebService

    WSDL支持4种消息交换方式:   1)单向(One-way):服务端接收消息:   2)请求响应(Request-response):服务端点接收请求消息,然后发送响应消息:   3)要求应答(So ...

  2. Gprinter Android SDK V2.0 使用说明

    佳博特约经销商,此店购买的打印机问题优先解决哟 https://shop107172033.taobao.com/index.htm?spm=2013.1.w5002-9520741823.2.V1p ...

  3. oracle数据表误删恢复

    1.查看回收站中的表: select object_name,original_name,partition_name,type,ts_name,createtime,droptime from re ...

  4. 关于 ASP.NET 验证码

    Session["CheckCode"] 这个..不懂神马意思.. .创建一个用户控件 用户名:TextBox 密码: TextBox 验证码:TextBox 验证码图片 < ...

  5. python 数据结构

    Python的数据结构主要分为set(),list[],和dict{}.这篇文章主要记载这几种结果在使用过程中的一些技巧或其中一些函数的用法区别. 1.函数get()与setdefault()区别: ...

  6. SGU 155.Cartesian Tree

    时间限制:0.25s 空间限制:6M 题意: 给出n(n< 50000)个含双关键字(key,val)的节点,构造一颗树使该树,按key值是一颗二分查找树,按val值是一个小根堆. Soluti ...

  7. html中发送邮箱的链接

  8. [转] 翻译-高质量JavaScript代码书写基本要点 ---张鑫旭

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=1173 原文作者:St ...

  9. Sass学习

    1.1下载地址: http://rubyinstaller.org/downloads 2.1 安装 SASS是Ruby语言写的,但是两者的语法没有关系.不懂Ruby,照样使用.只是必须先安装Ruby ...

  10. 使用jQuery UI方法

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...