HDU 6026 Deleting Edges】的更多相关文章

最短路. 先建一个只包含最短路的有向无环图,每一个点选择任意一条入边即可生成一个树形图,那么树的种类就等于每个点的入度乘积. #include <bits/stdc++.h> using namespace std; ; int n; ][]; ],f[]; ]; void spfa() { queue<int>Q; ;i<n;i++) f[i]=,dis[i] = 0x7FFFFFFF; dis[]=; Q.push(); f[]=; while(!Q.empty()) {…
Deleting Edges                                                                                  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)                                                                    …
Deleting Edges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 567    Accepted Submission(s): 210 Problem Description Little Q is crazy about graph theory, and now he creates a game about grap…
https://vjudge.net/problem/HDU-6026 我一直想不明白的是,它的乘法是如何保证n-1条边的.后来画了一张图大概能明白了. 结合最后的乘法二层循环的代码来看,当i=4的时候,j有1和3满足条件,3满足不用说是迪杰斯特拉本身跑出来的,1满足条件,而中间的点2.3也可以有自己本身的路径达到,最后满足共n-1条边. #include<iostream> #include<cstdio> #include<queue> #include<cs…
题意 有一个n个节点的无向图,结点编号从0-n-1,每条边的长度时1to9的一个正整数.现在要删除一些边(或者不删),使得到的新图满足下面两个要求. 1.新图是一颗树有n-1条边2.对于每个结点v(0ton-1)从0到v的距离要等于原图上从0到v的最短路 现在计算有多少种不同的图满足上面两个条件 分析 统计每个点可以到达最短路的入度值,然后相乘.这个题因为spfa写错了调了老久··· #include <cstdio> #include <cstring> #include <…
Problem Description Luxer is a really bad guy. He destroys everything he met. One day Luxer went to D-city. D-city has N D-points and M D-lines. Each D-line connects exactly two D-points. Luxer will destroy all the D-lines. The mayor of D-city wants…
D-City Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 18    Accepted Submission(s): 15 Problem Description Luxer is a really bad guy. He destroys everything he met. One day Luxer went to D-city…
D-City Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2933    Accepted Submission(s): 1038 Problem Description Luxer is a really bad guy. He destroys everything he met. One day Luxer went to D-…
1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ memset(cnt,,sizeof(cnt)); int l=strlen(a); ;i<l;i++){ cnt[a[i]]++; } for(int i='a';i<='z';i++){ printf("%c:%d\n",i,cnt[i]); } printf("\n…
D-City Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 3838    Accepted Submission(s): 1379 Problem Description Luxer is a really bad guy. He destroys everything he met. One day Luxer went to D-…