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\n",ans);
67     return 0;
68 }
时间: 2024-10-24 17:17:35

East Central North America Region 2015的相关文章

MPI Maelstrom(East Central North America 1996)(poj1502)

MPI Maelstrom 总时间限制:  1000ms 内存限制:  65536kB 描述 BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advisor

Gym-101673 :East Central North America Regional Contest (ECNA 2017)(寒假自训第8场)

A .Abstract Art 题意:求多个多边形的面积并. 思路:模板题. #include<bits/stdc++.h> using namespace std; typedef long long ll; const double inf=1e200; const double eps=1e-12; const double pi=4*atan(1.0); int dcmp(double x){ return fabs(x)<eps?0:(x<0?-1:1);} struct

[bfs,深度记录] East Central North America Regional Contest 2016 (ECNA 2016) D Lost in Translation

Problem D Lost in Translation The word is out that you’ve just finished writing a book entitled How to Ensure Victory at a Programming Contest and requests are flying in. Not surprisingly, many of these requests are from foreign countries, and while

North America Qualifier (2015)

https://icpc.baylor.edu/regionals/finder/north-america-qualifier-2015 一个人打.... B 概率问题公式见代码 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <queue> 5 #include <stack> 6 #include <vector> 7 #incl

2015 UESTC Winter Training #6【Regionals 2010 &gt;&gt; North America - Rocky Mountain】

2015 UESTC Winter Training #6 Regionals 2010 >> North America - Rocky Mountain A - Parenthesis 给一个长度不多于1000的表达式,只包含小写字母,加法运算,省略乘号的乘法运算和括号,输出去掉多余括号的表达式 括号匹配可以使用栈操作,只有两种情况可以去掉这一对括号: 左括号的左边是左边界.加法符号.左括号,并且右括号右边是有右边界.加法符号.右括号 如果括号内没有加法运算(括号内的括号里,也就是下一级括

That Diesel powered running watches north america doesn&#39;t need shift and legal requirements within any specific time

The form belonging to the Diesel's court case is totally distinct in addition to being very unlikely to find that remarkable high-quality because of shots solely. That face belonging to the Diesel powered is without a doubt everything that might be l

ACM-ICPC North America Qualifier 2014 Eight Queens

题意:问图是否满足八皇后. 解题思路:hash,dp,位运算 解题代码: 我的搓代码. 1 // File Name: a.cpp 2 // Author: darkdream 3 // Created Time: 2015年03月14日 星期六 12时00分44秒 4 5 #include<vector> 6 #include<list> 7 #include<map> 8 #include<set> 9 #include<deque> 10

ACM-ICPC North America Qualifier 2014 Units

题意:题如其名,给你n个单位 ,以及n-1个单位换算信息,让你把完整的单位换算链写出来. 解题思路:搜索 或者 floyd 解题代码: 1 // File Name: j.cpp 2 // Author: darkdream 3 // Created Time: 2015年03月14日 星期六 15时56分31秒 4 5 #include<vector> 6 #include<list> 7 #include<map> 8 #include<set> 9 #

ACM-ICPC North America Qualifier 2014 Narrow Art Gallery

题意:一个宽为2长为n的画廊,每个格子有一个值,问你关闭k个格子,使得画廊不堵塞且剩余值最大. 解题思路:dp[i][j][0/1]  表示 第 i个位置 ,选取第 j个格子关闭 ,关闭i位置的k格子的最小值. 解题代码: 1 // File Name: h.cpp 2 // Author: darkdream 3 // Created Time: 2015年03月14日 星期六 12时28分16秒 4 5 #include<vector> 6 #include<list> 7 #