CF888F.Connecting Vertices

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn points marked on the plane. The points are situated in such a way that they form a regular polygon (marked points are its vertices, and they are numbered in counter-clockwise order). You can draw n1n-1 segments, each connecting any two marked points, in such a way that all points have to be connected with each other (directly or indirectly).

But there are some restrictions. Firstly, some pairs of points cannot be connected directly and have to be connected undirectly. Secondly, the segments you draw must not intersect in any point apart from the marked points (that is, if any two segments intersect and their intersection is not a marked point, then the picture you have drawn is invalid).

How many ways are there to connect all vertices with n1n-1 segments? Two ways are considered different iff there exist some pair of points such that a segment is drawn between them in the first way of connection, but it is not drawn between these points in the second one. Since the answer might be large, output it modulo 109+710^{9}+7 .

输入格式

The first line contains one number nn ( 3<=n<=5003<=n<=500 ) — the number of marked points.

Then nn lines follow, each containing nn elements. ai,ja_{i,j} ( jj -th element of line ii ) is equal to 11 iff you can connect points ii and jj directly (otherwise ai,j=0a_{i,j}=0 ). It is guaranteed that for any pair of points ai,j=aj,ia_{i,j}=a_{j,i} , and for any point ai,i=0a_{i,i}=0 .

输出格式

Print the number of ways to connect points modulo 109+710^{9}+7 .

输入输出样例

  • 输入#1

    3
    0 0 1
    0 0 1
    1 1 0
    

    输出#1

    1
    
  • 输入#2

    4
    0 1 1 1
    1 0 1 1
    1 1 0 1
    1 1 1 0
    

    输出#2

    12
    
  • 输入#3

    3
    0 0 0
    0 0 1
    0 1 0
    

    输出#3

    0
    
首页