This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int m, n;
cin >> m >> n;
vector<vector<int>> grid(m+2, vector<int>(n+2, 0));
for (int y=0; y<m; y++) {
for (int x=0; x<n; x++) {
cin >> grid[y+1][x+1];
}
}
int k;
cin >> k;
vector<vector<bool>> sp_grid(m+2, vector<bool>(n+2, false));
vector<pair<int, int>> sp_cells(k);
for (int i=0; i<n; i++) {
int ri, ci;
cin >> ri >> ci;
sp_grid[ri+1][ci+1] = true;
sp_cells.emplace_back(ri, ci);
}
int sum = 0;
for (auto [ri, ci] : sp_cells) {
sum += grid[ri+1][ci] + grid[ri+1][ci+2] + grid[ri][ci+1] + grid[ri+2][ci+1] - \
min(min(grid[ri+1][ci], grid[ri+1][ci+2]), min(grid[ri][ci+1], grid[ri+2][ci+1]));
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |