博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 6026 Deleting Edges 江苏徐州邀请赛K
阅读量:4977 次
发布时间:2019-06-12

本文共 3569 字,大约阅读时间需要 11 分钟。

Deleting Edges

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 1693    Accepted Submission(s): 575

Problem Description
Little Q is crazy about graph theory, and now he creates a game about graphs and trees.
There is a bi-directional graph with 
n nodes, labeled from 0 to n1. Every edge has its length, which is a positive integer ranged from 1 to 9.
Now, Little Q wants to delete some edges (or delete nothing) in the graph to get a new graph, which satisfies the following requirements:
(1) The new graph is a tree with n1 edges.
(2) For every vertice v(0<v<n), the distance between 0 and v on the tree is equal to the length of shortest path from 0 to v in the original graph.
Little Q wonders the number of ways to delete edges to get such a satisfied graph. If there exists an edge between two nodes i and j, while in another graph there isn't such edge, then we regard the two graphs different.
Since the answer may be very large, please print the answer modulo 109+7.
 

 

Input
The input contains several test cases, no more than 10 test cases.
In each test case, the first line contains an integer 
n(1n50), denoting the number of nodes in the graph.
In the following n lines, every line contains a string with n characters. These strings describes the adjacency matrix of the graph. Suppose the j-th number of the i-th line is c(0c9), if c is a positive integer, there is an edge between i and j with length of c, if c=0, then there isn't any edge between i and j.
The input data ensure that the i-th number of the i-th line is always 0, and the j-th number of the i-th line is always equal to the i-th number of the j-th line.
 

 

Output
For each test case, print a single line containing a single integer, denoting the answer modulo 
109+7.
 

 

Sample Input
2 01 10 4 0123 1012 2101 3210
 

 

Sample Output
1 6
 

 

Source
 

 

Recommend
jiangzijing2015   |   We have carefully selected several similar problems for you:            
#include
using namespace std;const int mod=1e9+7;string s[100];int mp[100][100],n;int dis[100],vis[100],in_[100];struct node{ int to,v; friend bool operator < (node a,node b){
return a.v
(node a,node b){
return a.v>b.v;};};void dij(){ priority_queue
,greater
>q; memset(dis,0x3f,sizeof(dis)); memset(vis,0,sizeof(vis)); dis[0]=0;vis[0]=1;q.push({
0,0}); while(!q.empty()){ node u=q.top();q.pop(); if(u.v>dis[u.to]) continue; for(int i=0;i
dis[u.to]+mp[u.to][i]){ dis[i]=dis[u.to]+mp[u.to][i]; q.push({i,dis[i]}); } } }}int main(){ while(cin>>n){ for(int i=0;i
>s[i]; memset(in_,0,sizeof(in_)); for(int i=0;i
View Code
#include
using namespace std;const int mod=1e9+7;string s[100];int mp[100][100],n;int dis[100],vis[100],in_[100];void dij(){ //priority_queue
,greater
>q; queue
q; memset(dis,0x3f,sizeof(dis)); memset(vis,0,sizeof(vis)); dis[0]=0;vis[0]=1;q.push(0); while(!q.empty()){ int u=q.front();q.pop();vis[u]=0; for(int i=0;i
dis[u]+mp[u][i]){ dis[i]=dis[u]+mp[u][i]; if(!vis[i]){ q.push(i); vis[i]=1; } } } }}int main(){ while(cin>>n){ for(int i=0;i
>s[i]; memset(in_,0,sizeof(in_)); for(int i=0;i
View Code

 

 
 

转载于:https://www.cnblogs.com/vainglory/p/9142280.html

你可能感兴趣的文章
求输入成绩的平均分
查看>>
php PDO (转载)
查看>>
wordpress自动截取文章摘要代码
查看>>
[置顶] 一名优秀的程序设计师是如何管理知识的?
查看>>
highcharts 图表实例
查看>>
highcharts曲线图
查看>>
extjs动态改变样式
查看>>
宏定义
查看>>
笔记:git基本操作
查看>>
生成php所需要的APNS Service pem证书的步骤
查看>>
JavaWeb之JSON
查看>>
HOT SUMMER 每天都是不一样,积极的去感受生活 C#关闭IE相应的窗口 .
查看>>
optionMenu-普通菜单使用
查看>>
2016-2017-2点集拓扑作业[本科生上课时]讲解视频
查看>>
【MemSQL Start[c]UP 3.0 - Round 1 C】 Pie Rules
查看>>
Ognl中“%”、“#”、“$”详解
查看>>
我对应用软件——美团的看法
查看>>
struts2.x + Tiles2.x读取多个xml 配置文件
查看>>
表单校验之datatype
查看>>
python第六篇文件处理类型
查看>>