| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 7 초 | 1024 MB | 18 | 10 | 5 | 62.500% |
You are given a two-dimensional array of integers of size $N \times K,ドル $A$ $=$ $A_{0,0},ドル $A_{0,1},ドル $\dots,ドル $A_{0,K-1},ドル $A_{1,0},ドル $\dots,ドル $A_{N-1,K-1}$ and also arrays of integers of size $M,ドル $U$ $=$ $U_{0},ドル $\dots,ドル $U_{M-1}$ and $V$ $=$ $V_0,ドル $\dots,ドル $V_{M-1}$.
Jimin made a cute weighted undirected graph $G,ドル which is a complete graph with the weight of an edge connecting vertices $u$ and $v$ is $\left\lvert A_{u, (v ,円 \bmod ,円 K)} - A_{v, (u ,円 \bmod ,円 K)} \right\rvert$. Eunsoo then found the minimum spanning tree of $G$.
However, Jongyoung brutally deleted edges of $G$ connecting $U_i$ and $V_i$ for 0ドル \le i \le M-1$. Note that $G$ may not be connected after deleting the edges.
Now, to help poor Jimin and Eunsoo, you should find the minimum spanning forest of $G$. A minimum spanning forest is a union of the minimum spanning trees of its connected components.
The first line contains three space-separated integers, $N,ドル $K,ドル and $M$.
Each of the following $N$ lines contains $K$ space-separated integers, $A_{i,0},$ $\dots,$ $A_{i,K-1}$. $(0 \le i \le N-1)$
Each of the following $M$ lines contains two space-separated integers, $U_i$ and $V_i$. $(0 \le i \le M-1)$
Output the sum of the weight of edges in the minimum spanning forest of $G$.
This subtask has an additional constraint:
This subtask has additional constraints:
This subtask has additional constraints:
This subtask has no additional constraints.
7 1 7 0 1 2 1 2 -5 -1 4 5 1 3 4 6 0 4 2 5 1 4 3 4
8
7 2 7 5 1 4 5 -2 4 4 1 -5 -5 2 -1 3 3 5 6 0 5 0 3 1 2 4 6 2 3 2 6
11
University > KAIST > KAIST RUN Spring Contest > 2022 KAIST RUN Spring Contest H번