QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#7500. 数圈圈

Statistics

给你一张无向图 $G$,请你数数其中有多少个 $k$ 元环。

输入格式

第一行输入三个正整数 $n, k$,表示图的顶点数和要数的环长。

接下来 $n$ 行输入图的邻接矩阵,$A_{ij} = 1$ 代表 $(i,j)$ 有边,保证无自环并且是无向图。

输出格式

输出一个数表示环的数量。

样例数据

样例 1~4 输入

6 [k]
001110
001011
110011
100010
111100
011000

样例 1~4 输出

k=3: 4
k=4: 3
k=5: 2
k=6: 1

样例 5~8 输入

10 [k]
0100011001
1010101100
0101001101
0010101001
0101011000
1000100101
1111100100
0110011010
0000000101
1011010010

样例 5~8 输出

k=3: 10
k=4: 27
k=5: 66
k=6: 123

样例 9 输入

20 4
01111001011011011110
10101010100001000100
11011101010010111110
10101110110010000010
11110010001101111111
00110001000100100100
01011001111011011110
10100110110011011001
01010011000011001110
10110011001110100111
10001010010011111000
00001100010010110001
10110011111100111100
11001011101000010101
00101100011110011100
10101011001111100000
10101011101010100101
11101110110011101010
10111010110000000100
00001001010101001000

样例 9 输出

1267

提示

注:前两个样例实际上对应于 $4$ 个样例,也即将输入中的 [k] 替换成 $3, 4, 5, 6$ 对应的结果。

子任务

对于 $20\%$ 的数据,保证 $n\leq 10$。

对于另外 $10\%$ 的数据,保证 $k=3$。

对于另外 $20\%$ 的数据,保证 $k=4$。

对于另外 $30\%$ 的数据,保证 $k=5$。

对于 $100\%$ 的数据,保证 $1\leq n\leq 300, k\leq 6$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.