QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 100 قابلة للهجوم ✓

#7500. 数圈圈

الإحصائيات

無向グラフ $G$ が与えられます。このグラフに含まれる $k$ 元環(長さ $k$ のサイクル)の数を数えてください。

入力

1行目に2つの正整数 $n, k$ が与えられます。これらはグラフの頂点数と数えるべき環の長さを表します。

続く $n$ 行にはグラフの隣接行列が与えられます。$A_{ij} = 1$ は $(i,j)$ 間に辺があることを意味します。自己ループは存在せず、無向グラフであることが保証されます。

出力

環の数を出力してください。

制約

  • データセットの $20\%$ について、$n \leq 10$ を満たす。
  • 別の $10\%$ のデータセットについて、$k=3$ を満たす。
  • 別の $20\%$ のデータセットについて、$k=4$ を満たす。
  • 別の $30\%$ のデータセットについて、$k=5$ を満たす。
  • すべてのデータセットについて、$1 \leq n \leq 300, k \leq 6$ を満たす。

入出力例

入力 1

6 3
001110
001011
110011
100010
111100
011000

出力 1

4

入力 2

6 4
001110
001011
110011
100010
111100
011000

出力 2

3

入力 3

6 5
001110
001011
110011
100010
111100
011000

出力 3

2

入力 4

6 6
001110
001011
110011
100010
111100
011000

出力 4

1

入力 5

10 3
0100011001
1010101100
0101001101
0010101001
0101011000
1000100101
1111100100
0110011010
0000000101
1011010010

出力 5

10

入力 6

10 4
0100011001
1010101100
0101001101
0010101001
0101011000
1000100101
1111100100
0110011010
0000000101
1011010010

出力 6

27

入力 7

10 5
0100011001
1010101100
0101001101
0010101001
0101011000
1000100101
1111100100
0110011010
0000000101
1011010010

出力 7

66

入力 8

10 6
0100011001
1010101100
0101001101
0010101001
0101011000
1000100101
1111100100
0110011010
0000000101
1011010010

出力 8

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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.