mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 19:08:47 +00:00
parent
f356e78e38
commit
4e1c72a8e0
74
S2OJ/1785/1785.cpp
Normal file
74
S2OJ/1785/1785.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 305;
|
||||
|
||||
int n, m, k, a[N][N], f[N][N], ans = 0x3f3f3f3f;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m >> k;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= m; j++) {
|
||||
cin >> a[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
memset(f, 0x3f, sizeof(f));
|
||||
|
||||
for (int i = 1; i <= m; i++) {
|
||||
for (int j = i + 1; j <= m; j++) {
|
||||
f[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < n; i++) {
|
||||
for (int j = 1; j <= m; j++) {
|
||||
for (int l = j + 1; l <= m; l++) {
|
||||
f[j][l] += a[i][j] + a[i][l];
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 1; j <= m; j++) {
|
||||
for (int l = j + 1; l <= m; l++) {
|
||||
f[j][l] = std::min({f[j][l], f[j - 1][l] + k, f[j][l - 1] + k});
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 1; j <= m; j++) {
|
||||
for (int l = m; l > j; l--) {
|
||||
f[j][l] = std::min({f[j][l], f[j - 1][l] + k, f[j][l + 1] + k});
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = m; j; j--) {
|
||||
for (int l = j + 1; l <= m; l++) {
|
||||
f[j][l] = std::min({f[j][l], f[j + 1][l] + k, f[j][l - 1] + k});
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = m; j; j--) {
|
||||
for (int l = m; l > j; l--) {
|
||||
f[j][l] = std::min({f[j][l], f[j + 1][l] + k, f[j][l + 1] + k});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= m; i++) {
|
||||
for (int j = i + 1; j <= m; j++) {
|
||||
ans = std::min(ans, f[i][j] + a[n][i] + a[n][j]);
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1785/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room1.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room10.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room2.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room3.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room4.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room5.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room6.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room7.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room8.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room9.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1785/data/room9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1785/data/room9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user