East Central North America Region 2015

时间:2023-03-09 03:13:36
East Central North America Region 2015

E

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

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <list>
#include <map>
#include <stack>
#include <vector>
#include <cstring>
#include <sstream>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long void fre() {
freopen("in.txt","r",stdin);
}
inline int r() {
int x=,f=;char ch=getchar();
while(ch>''||ch<'') {if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<='') { x=x*+ch-'';ch=getchar();}return x*f;
} vector<int>g[];
LL countt[];
LL val[]={}; int main(){
int n,m,s,t;
n=r();
m=r();
s=r();
t=r();
for(int i=;i<=n;i++)
g[i].clear();
for(int i=;i<m;i++){
int x,y;
x=r();
y=r();
g[x].push_back(y);
g[y].push_back(x);
}
val[s]=;
for(int i=;i<=t;i++){
for(int j=;j<n;j++)
countt[j]=;
for(int j=;j<n;j++){
LL num=val[j];
for(int p=;p<(int)g[j].size();p++){
int v=g[j][p];
countt[v]+=num;
}
}
for(int j=;j<n;j++){
val[j]=countt[j];
}
}
LL ans=;
for(int i=;i<n;i++)
ans+=val[i];
printf("%lld\n",ans);
return ;
}