Submission #463631

#TimeUsernameProblemLanguageResultExecution timeMemory
463631EliasT-Covering (eJOI19_covering)C++17
Compilation error
0 ms0 KiB
#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;
		}
	}

	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;
}

Compilation message (stderr)

covering.cpp: In function 'int main()':
covering.cpp:43:4: error: return-statement with no value, in function returning 'int' [-fpermissive]
   43 |    return;
      |    ^~~~~~