#P5687. [CSP-S 2019 江西] 网格图
[CSP-S 2019 江西] 网格图
Description
Given an grid graph, rows are numbered from and columns are numbered from . Each point can be represented by its row number and column number as .
There is an edge with weight between points and , where .
There is an edge with weight between points and , where .
Please find the minimum spanning tree of this grid graph.
Input Format
The first line contains two positive integers , representing the number of rows and columns.
The second line contains positive integers, representing .
The third line contains positive integers, representing .
Output Format
Output a single integer in one line, representing the answer.
3 3
2 4 3
1 3 2
16
Hint
Explanation of Sample Input/Output 1
The edges in the minimum spanning tree include: all edges in the first row, and all edges in the first, second, and third columns.
Constraints
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号