Logo
(追記) (追記ここまで)

19075번 - K-matching 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
9 초 512 MB226538.462%

문제

Consider a graph $G$ with $n \cdot m$ nodes $(i, j)$ (1ドル \leq i \leq n,ドル 1ドル \leq j \leq m$). There is an edge between two nodes $(a, b)$ and $(c, d)$ if and only if $|a - c| + |b - d| = 1$. Each edge has a weight.

Calculate the minimum weight of a $K$-matching in $G$.

An edge set $S$ is a matching of $G = \langle V, E \rangle$ if and only if each node in $V$ is connected to at most one edge in $S$. A matching $S$ is a $K$-matching if and only if $|S| = K$. The weight of a matching $S$ is the sum of the weights of the edges in $S$. And finally, the minimum weight $K$-matching of $G$ is defined as the $K$-matching of $G$ with the minimum possible weight.

입력

The first line contains an integer $t,ドル the number of test cases (1ドル \leq t \leq 1000$). It is guaranteed that there are at most 3ドル$ test cases with $n > 100$.

For each test case, the first line contains three integers $n,ドル $m$ and $K$ (1ドル \leq n \leq 4 \cdot 10^4,ドル 1ドル \leq m \leq 4,ドル 1ドル \leq K \leq \lfloor \frac{n \cdot m}{2} \rfloor$).

Then $n - 1$ lines follow, each of these lines contains $m$ integers $A_{i, j}$: the weights of edges between $(i, j)$ and $(i + 1, j)$ (1ドル \leq A_{i, j} \leq 10^9$).

If $m > 1,ドル then $n$ more lines follow, each of these lines contains $m - 1$ integers $B_{i, j}$: the weights of the edge between $(i, j)$ and $(i, j + 1)$ (1ドル \leq B_{i, j} \leq 10^9$).

출력

For each test case, print a single line with a single integer: the required minimum weight.

제한

예제 입력 1

3
3 3 1
3 4 5
8 9 10
1 2
6 7
11 12
3 3 2
3 4 5
8 9 10
1 2
6 7
11 12
3 3 3
3 4 5
8 9 10
1 2
6 7
11 12

예제 출력 1

1
5
12

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 4: Ruyi Ji Contest 2 J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /