{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"MD","content":"Bạn có một lưới ô vuông H hàng W cột. Ô ở hàng i cột j gọi là ô (i, j). Bạn cần xây 2 căn nhà ở hai ô khác nhau và đường đi để nối chúng. Giả sử bạn chọn ô (x1, y1) và (x2, y2), thì chi phí sẽ là A(x1, y1) + A(x2, y2) + C * (|x1 - x2| + |y1 - y2|). Tìm cách xây sao cho chi phí là nhỏ nhất."}},{"title":"Constraints","value":{"format":"MD","content":"2 \u003c\u003d H, W \u003c\u003d 1000\n1 \u003c\u003d C, A(i, j) \u003c\u003d 10^9\nToàn bộ đều là số nguyên dương."}},{"title":"Input","value":{"format":"MD","content":"Dữ liệu đầu vào có dạng:\nH W C\nA(1, 1) A(1, 2) ... A(1, W)\nA(2, 1) A(2, 2) ... A(2, W)\n...\nA(H, 1) A(H, 2) ... A(H, W)"}},{"title":"Output","value":{"format":"MD","content":"Một số nguyên là đáp án bài toán."}},{"title":"Sample Input 1","value":{"format":"MD","content":"3 4 2\n1 7 7 9\n9 6 3 7\n7 8 6 4\n"}},{"title":"Sample Output 1","value":{"format":"MD","content":"10\n"}},{"title":"Sample Input 2","value":{"format":"MD","content":"3 3 1000000000\n1000000 1000000 1\n1000000 1000000 1000000\n1 1000000 1000000\n"}},{"title":"Sample Output 2","value":{"format":"MD","content":"1001000001\n"}}]}