编程介的小学生 2019-11-19 17:54 采纳率: 20.5%
浏览 80

Arborescence Counting 怎么写的呢

Problem Description
"In graph theory, an arborescence is a directed graph in which, for a vertex v called the root and any other vertex u, there is exactly one directed path rom v to u. In other words, an arborescence is a directed, rooted tree in which all edges point away from the root. Every arborescence is a directed acyclic graph."-- from Wikipedia, the free encyclopedia

You are given a directed graph with N vertices, and your task is to count the number of different arborescences of size N that can be found in the given graph.

Two arborescences are considered different when they consist of different edges.

Input
Input consists of multiple test cases.
For each test case, the first line contains one integer N described as above.
N lines follows, each consists of N characters, either '0' or '1', representing the adjacency matrix of the graph.
The directed graph contains edge (i,j) if and only if the jth character of the ith line of the matrix is '1'.
The graph consists of no more than 8 vertices.
End of input is indicated by a line consisting of a single 0.

Output
For each test case, output one line consisting of one single integer, the number of arborescences.

Sample Input
2
00
00
2
01
10
0

Sample Output
0
2

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?