이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, m, k;
struct Tetro
{
int x, y;
};
vector<vector<int>> grid;
vector<Tetro> tetros;
signed main()
{
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >> m >> n;
grid = vector<vector<int>>(n, vector<int>(m));
for (int y = 0; y < m; y++)
for (int x = 0; x < n; x++)
cin >> grid[x][y];
cin >> k;
tetros = vector<Tetro>(k);
for (int i = 0; i < k; i++)
{
int x, y;
cin >> y >> x;
tetros[i] = {x, y};
// make sure it is possible to place the current tetro
if ((x == 0 || x == n - 1) && (y == 0 && y == m - 1))
{
cout << "No";
return 0;
}
}
int solution = 0;
for (Tetro t : tetros)
{
int a = grid[t.x + 1][t.y + 0];
int b = grid[t.x - 1][t.y + 0];
int c = grid[t.x + 0][t.y + 1];
int d = grid[t.x + 0][t.y - 1];
solution += a + b + c + d - min(a, min(b, min(c, d)));
}
cout << solution;
}
# | 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... |