POJ:2139-Six Degrees of Cowvin Bacon】的更多相关文章

http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=78207 看懂题就好. 求某一办公室到其他办公室的最短距离. 多组输入,n表示n条关系,下面n次每次输入 x y d表示x到y的距离是d. 输出办公室的编号和距离. 因为 顶点数小于10,直接floyed求出所有距离之后,枚举出最短距离即可. /* *********************************************** Author : zch Cre…
Six Degrees of Cowvin Bacon Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 2   Accepted Submission(s) : 1 Problem Description The cows have been making movies lately, so they are ready to play…
本题链接:http://poj.org/problem?id=2139 Description:     The cows have been making movies lately, so they are ready to play a variant of the famous game "Six Degrees of Kevin Bacon".      The game works like this: each cow is considered to be zero d…
题目: http://poj.org/problem?id=2139 题解:N只牛,在一组的两只牛,分别两只之间为 “1度”,自己到自己为0度,M组牛.求,N只牛之中,两只牛之间 平均最短度数*100.模板Floyd算法,求任意两点之间最短路径. #include <iostream> #include <algorithm> #include <iomanip> using namespace std; + ; ; int N, M; // N个牛 ,M组电影 //不…
floyd-warshall算法 通过dp思想 求任意两点之间最短距离 重复利用数组实现方式dist[i][j] i - j的最短距离 for(int k = 1; k <= N; k++) for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]); 非常好实现 O(V^3) 这里贴一道刚好用到的题 http://poj.org…
题意:如果两头牛在同一部电影中出现过,那么这两头牛的度就为1, 如果这两头牛a,b没有在同一部电影中出现过,但a,b分别与c在同一部电影中出现过,那么a,b的度为2.以此类推,a与b之间有n头媒介牛,那么a,b的度为n+1. 给出m部电影,每一部给出牛的个数,和牛的编号.问那一头到其他每头牛的度数平均值最小,输出最小平均值乘100 思路:到所有牛的度数的平均值最小,也就是到所有牛的度数总和最小.那么就是找这头牛到其他每头牛的最小度,也就是最短路径,相加再除以(n-1)就是最小平均值.对于如何确定…
题意:奶牛拍电影,如果2个奶牛在同一场电影里演出,她们的合作度是1,如果ab合作,bc合作,ac的合作度为2,问哪一头牛到其他牛的合作度平均值最小再乘100 思路:floyd模板题 #include<cstdio> #include<cmath> #include<cstring> #include<iostream> #include<algorithm> ][],a[]; int read(){ ,t=; ;ch=getchar();} +c…
水题,Floyd. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ][]; ]; int n,m; int main() { scanf("%d%d",&n,&m); ;i<=n;i++) { ;j<=n;j++) { ; else dis[i][j]=0x7fffffff; } } ;i<=m;i++) { i…
传送门:http://poj.org/problem?id=2139 Six Degrees of Cowvin Bacon Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6709 Accepted: 3122 Description The cows have been making movies lately, so they are ready to play a variant of the famous game…
Six Degrees of Cowvin Bacon Descriptions 数学课上,WNJXYK忽然发现人缘也是可以被量化的,我们用一个人到其他所有人的平均距离来量化计算. 在这里定义人与人的距离:1.自己与自己的距离为02.如果A和B属于同一个小团体,那么他们之间的距离为13.如果A与B属于一个小团体,B与C属于一个小团体,且A与C不同属于任何一个小团体,那么A与C的距离为2(A联系C,经过B.C两个人)4.以此类推 班里有N个人 (2 <= N <= 300),共有M对小团体关系(…
The cows have been making movies lately, so they are ready to play a variant of the famous game "Six Degrees of Kevin Bacon". The game works like this: each cow is considered to be zero degrees of separation (degrees) away from herself. If two d…
牛与电影 题目大意:就是一群牛,又在玩游戏了(怎么你们经常玩游戏),这个游戏规则如下,把牛拆分成一个一个组,并且定义一个“度”,规定在一个组的牛与他自己的度为0,与其他牛的度为1,不同组的牛不存在度,但是如果牛与牛之间有联系,那么度就会想加,这一题所有的牛都会与其他所有的牛有联系,问你哪只牛与其他牛的度的总数最少,求这个总数的平均值. 那么这一题貌似把牛拆分成一个一个的区间,但是我们仔细想一下,其实啊这个组是不重要的,他只是影响了牛与牛之间有没有直接相连,其实仔细读下来我们直接建图就可以了,每一…
思路: floyd 实现: #include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; ][], n, m, k; const int INF = 0x3f3f3f3f; int main() { memset(a, 0x3f, sizeof(a)); cin >>…
水题,随手敲过 一看就是最短路问题,a,b演同一场电影则他们的距离为1 默认全部两两原始距离无穷,到自身为0 输入全部数据处理后floyd 然后照它说的求平均分离度 再找最小的,×100取整输出 #include <cstdio> #include <algorithm> #include <iostream> using namespace std; int cownum,filmnum; int film[11111][333]; int g[333][333];…
普通的Floyd了分分秒可以水过,结果在submit前删调试段落的时候把程序本体给删了吃了两个WA…… #include<iostream> #include<cstring> #include<cstdio> ; using namespace std; ; int len[MAXN][MAXN]; int f[MAXN][MAXN]; int n,m; int main() { scanf("%d%d",&n,&m); ;i<…
poj:4091:The Closest M Points 题目 描写叙述 每到饭点,就又到了一日几度的小L纠结去哪吃饭的时候了.由于有太多太多好吃的地方能够去吃,而小L又比較懒不想走太远,所以小L会先找到距离他近期的M家餐馆然后再做筛选. 小L如今所在的位置和每家餐馆的位置用同一笛卡尔坐标系中的点表示,而点与点之间的距离为欧几里得距离,对于点p = (p1, p2,..., pn)和点q = (q1,q2,..., qn),两者的距离定义例如以下 现给出在K维空间中小L所处的位置的坐标以及n个…
http://poj.org/problem?id=1182 Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种. 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类. 第二种说法是"2 X Y",表示X吃Y. 此人对N个动物,用上述两种说法,一句接一句地说出…
题目链接:http://poj.org/problem?id=2229 Sumsets Time Limit: 2000MS Memory Limit: 200000K Total Submissions: 21845 Accepted: 8454 Description Farmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use o…
题目链接:http://poj.org/problem?id=3126 Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 25215 Accepted: 13889 Description The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they woul…
原题链接:http://poj.org/problem?id=2429 GCD & LCM Inverse Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17639 Accepted: 3237 Description Given two positive integers a and b, we can easily calculate the greatest common divisor (GCD) and the l…
传送门:http://poj.org/problem?id=3614 Sunscreen Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10136 Accepted: 3544 Description To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with sunscreen when…
传送门:http://poj.org/problem?id=2377 Bad Cowtractors Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 17373 Accepted: 7040 Description Bessie has been hired to build a cheap internet network among Farmer John's N (2 <= N <= 1,000) barns that…
传送门:http://poj.org/problem?id=1017 Packets Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 59106 Accepted: 20072 Description A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5…
传送门:http://poj.org/problem?id=3190 Stall Reservations Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9173 Accepted: 3208 Special Judge Description Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be mil…
传送门:http://poj.org/problem?id=1330 Nearest Common Ancestors Time Limit: 1000MS Memory Limit: 10000K Description A rooted tree is a well-known data structure in computer science and engineering. An example is shown below: In the figure, each node is l…
传送门:http://poj.org/problem?id=2060 Taxi Cab Scheme Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7260 Accepted: 2972 Description Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination…
题目链接:http://poj.org/problem?id=2411 解题心得: 可以说是很经典的一个状压dp了,写dfs遍历肯定是要超时的,这个题的状态转移方程对新手来说有点吃力. 状态转移用的是上凸法,就是如果一行中(除了最后一行)有一个是空位,那么必定是下面一行竖着摆放的矩形,这样才符合条件.这样就把两行中的状态联系起来了,枚举每两行的状态来进行检验,还可以进行状态的累加. 这个题还有一些小技巧, 如果列数大于行数可以将列和行互换,因为在计算行和列的复杂度是完全不同的,列是o(2^n),…
传送门:http://poj.org/problem?id=2955 Brackets Time Limit: 1000MS Memory Limit: 65536K Description We give the following inductive definition of a "regular brackets" sequence: the empty sequence is a regular brackets sequence, if s is a regular bra…
传送门:http://poj.org/problem?id=2342 Anniversary party Time Limit: 1000MS Memory Limit: 65536K Description There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of empl…
原题传送:http://poj.org/problem?id=3020 Antenna Placement Time Limit: 1000MS Memory Limit: 65536K Description The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking…