• East Central North America Region 2015


    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
    ",ans);
    67     return 0;
    68 }
  • 相关阅读:
    48音标
    business expressions(二)
    Pick up lines搭讪
    Greetings
    business expressions(一)
    analyzing problems
    business meeting
    idea缓存目录mac cache
    Sublime 3156 LICENSE key
    React从0到1
  • 原文地址:https://www.cnblogs.com/ITUPC/p/5572849.html
Copyright © 2020-2023  润新知