이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |