码迷,mamicode.com
首页 > 其他好文 > 详细

East Central North America Region 2015

时间:2016-06-09 23:31:40      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

E

每过一秒,当前点会把它的值传递给所有相邻点,问t时刻该图的值

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 #include <list>
 5 #include <map>
 6 #include <stack>
 7 #include <vector>
 8 #include <cstring>
 9 #include <sstream>
10 #include <string>
11 #include <cmath>
12 #include <queue>
13 using namespace std;
14 #define clc(a,b) memset(a,b,sizeof(a))
15 #define inf 0x3f3f3f3f
16 const int N=10010;
17 const int MOD = 1e9+7;
18 #define LL long long
19  
20 void fre() {
21     freopen("in.txt","r",stdin);
22 }
23 inline int r() {
24     int x=0,f=1;char ch=getchar();
25     while(ch>9||ch<0) {if(ch==-) f=-1;ch=getchar();}
26     while(ch>=0&&ch<=9) { x=x*10+ch-0;ch=getchar();}return x*f;
27 }
28  
29 vector<int>g[101]; 
30 LL countt[110];
31 LL val[110]={0};
32  
33 int main(){
34     int n,m,s,t;
35     n=r();
36     m=r();
37     s=r();
38     t=r();
39     for(int i=0;i<=n;i++)
40         g[i].clear();
41     for(int i=0;i<m;i++){
42         int x,y;
43         x=r();
44         y=r();
45         g[x].push_back(y);
46         g[y].push_back(x);
47     }
48     val[s]=1;
49     for(int i=1;i<=t;i++){
50         for(int j=0;j<n;j++)
51             countt[j]=0;
52         for(int j=0;j<n;j++){
53             LL num=val[j];
54             for(int p=0;p<(int)g[j].size();p++){
55                 int v=g[j][p];
56                 countt[v]+=num;
57             }
58         }
59         for(int j=0;j<n;j++){
60             val[j]=countt[j];
61         }
62     }
63     LL ans=0;
64     for(int i=0;i<n;i++)
65         ans+=val[i];
66     printf("%lld\n",ans);
67     return 0;
68 }

 

East Central North America Region 2015

标签:

原文地址:http://www.cnblogs.com/ITUPC/p/5572849.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!