A11421 | Connecting Vertices
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ 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 $n-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 $n-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 $10^{9}+7$ .
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 $n-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 $10^{9}+7$ .
输入格式
The first line contains one number $n$ ( $3<=n<=500$ ) — the number of marked points.
Then $n$ lines follow, each containing $n$ elements. $a_{i,j}$ ( $j$ -th element of line $i$ ) is equal to $1$ iff you can connect points $i$ and $j$ directly (otherwise $a_{i,j}=0$ ). It is guaranteed that for any pair of points $a_{i,j}=a_{j,i}$ , and for any point $a_{i,i}=0$ .
Then $n$ lines follow, each containing $n$ elements. $a_{i,j}$ ( $j$ -th element of line $i$ ) is equal to $1$ iff you can connect points $i$ and $j$ directly (otherwise $a_{i,j}=0$ ). It is guaranteed that for any pair of points $a_{i,j}=a_{j,i}$ , and for any point $a_{i,i}=0$ .
输出格式
Print the number of ways to connect points modulo $10^{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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted