【宽搜】ECNA 2015 E Squawk Virus (Codeforces GYM 100825)

时间:2022-09-05 08:39:44

题目链接:

  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 &lpar;Codeforces GYM 100825&rpar;

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

  2. 【宽搜】BAPC2014 J Jury Jeopardy &lpar;Codeforces GYM 100526&rpar;

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

  3. 【宽搜】ECNA 2015 D Rings &lpar;Codeforces GYM 100825&rpar;

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

  4. 【模拟】ECNA 2015 I What&&num;39&semi;s on the Grille&quest; &lpar;Codeforces GYM 100825&rpar;

    题目链接: 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&lpar;CF的某道&rpar; &amp&semi; 鬼畜宽搜

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

随机推荐

  1. jqgrid cellEdit为true的时候,默认选中单元格值的解决方案

    jqgrid cellEdit为true的时候,点击单元格的时候,鼠标在单元格最前面闪. 这时候如果要修改数字内容,非常麻烦.要全选单元格内容,不然不好改. 点击单元格的时候,默认选中单元格值的解决方 ...

  2. MEF 生命周期PartCreationPolicy

    为什么要单独把这个生命周期捞出来单独说一说呢?因为我今天就被这个东东坑了一把……新加了一个界面,第二次打开界面的时候会报错“指定的元素已经是另一个元素的逻辑子元素”.好嘛,我一看,哟,感觉就是xaml ...

  3. servlet service&lpar;&rpar; for servlet jsp throws null pointer exception

    这么一件小事折腾了一个多小时,google也上不去,对百度我就不吐槽什么了,最后用bing查出了满意的结果.一般程序中不要显式把jsp.jar和servlet.jar放在Lib目录下,因为tomcat ...

  4. 再议C&plus;&plus;的性能

    最近在公司里的项目做的是性能优化,相关性能调优的经验总结也在前一篇文章里说了.这里再说一说和性能相关的东西.主要针对的是C++类库中常用的一些数据结构,比方说std::string.顺序容器(vect ...

  5. DRAM 内存介绍&lpar;二&rpar;

    参考资料:http://www.anandtech.com/show/3851/everything-you-always-wanted-to-know-about-sdram-memory-but- ...

  6. sencha项目升级

    对于已经开发好的sencha项目进行升级,要做的有以下几步(以sencha2.2.0升级到sencha2.3.1为例): 1,下载Sencha-2.3.1sdk,下载地址:http://cdn.sen ...

  7. CentOS系统下做nginx和tomcat负载均衡

    系统总是频繁更新,为了避免更新系统的时候领导看不到东西,打算用ngix做代理,后台部署两个tomcat做负载均衡,避免更新一台就无法使用系统的问题,这两天看了写资料,把几个关键点记录在这里以便备忘. ...

  8. IIS的WebGarden、WebFarm和StateServer

    开启IIS的WebGarden.WebFarm和StateServer之旅 前言 公司系统虽然配置有1台NLB后拖4台App Server最后搭一台强劲无比的DB Server,但每天下午4点左右总被 ...

  9. scala中java并发编程

    Runnable/Callable 线程(Thread) Executors/ExecutorService Future 线程安全问题 示例:搜索引擎 解决方案 Runnable/Callable ...

  10. Linux&period;杀毒&period;Centos安装杀毒软件Clam

    Linux系统用了几年, 甚少中毒 但前不久在阿里云的服务器被种马,折腾了几周才解决干净 感觉还是装个杀毒/马软件定期扫一扫比较稳妥, 这个Clam是免费的, 安装和配置办法记录如下: 已验证适用环境 ...