Submission #340315

# Submission time Handle Problem Language Result Execution time Memory
340315 2020-12-27T12:19:37 Z _ani UFO (IZhO14_ufo) C++17
30 / 100
483 ms 16620 KB
#define BUGOARR(x) { cerr << "{ "; for(auto& i: (x))cerr<<i<<' ';cerr<<"}\n";}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int rupd[50'002][2], cupd[50'002][2];
vector<vector<int>> a;
int main()
{
	int n, m, r, k, p;
	cin >> n >> m >> r >> k >> p;
	a.resize(n);
	for (int i = 0; i < n; i++)
		a[i].resize(m);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	while (k--)
	{
		char d;
		int r, c, t, x;
		cin >> d >> x >> t;
		if (d == 'N' || d == 'S')
		{
			if (d == 'N')
				c = 0;
			else c = 1;
			cupd[x - 1][c]++;
		}
		else
		{
			if (d == 'W')
				r = 0;
			else r = 1;
			rupd[x - 1][r]++;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (rupd[i][1]) {
			int x = rupd[i][1] * r;
			int j = 0;
			while (x && j < m)
			{
				int tmp = min(a[i][j], min(x, rupd[i][1]));
				a[i][j] -= tmp;
				x -= tmp;
				j++;
			}
		}
		if (rupd[i][0]) {
			int x = rupd[i][0] * r;
			int j = m - 1;
			while (x && j >= 0)
			{
				int tmp = min(a[i][j], min(x, rupd[i][0]));
				a[i][j] -= tmp;
				x -= tmp;
				j--;
			}
		}
	}
	for (int j = 0; j < m; j++)
	{
		if (cupd[j][1]) {
			int x = cupd[j][1] * r;
			int i = 0;
			while (x && i < n)
			{
				int tmp = min(a[i][j], min(x, cupd[j][1]));
				a[i][j] -= tmp;
				x -= tmp;
				i++;
			}
		}
		if (cupd[j][0]) {
			int x = cupd[j][0] * r;
			int i = n - 1;
			while (x && i >= 0)
			{
				int tmp = min(a[i][j], min(x, cupd[j][0]));
				a[i][j] -= tmp;
				x -= tmp;
				i--;
			}
		}
	}/*
	for (auto& x : a)
		BUGOARR(x);*/
	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			if (i + p > n || j + p > m)continue;
			int cur = 0;
			for (int l = i; l < i + p; l++)
				for (int r = j; r < j + p; r++)
					cur += a[l][r];
			ans = max(ans, cur);
		}
	cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Incorrect 2 ms 364 KB Output isn't correct
4 Incorrect 8 ms 492 KB Output isn't correct
5 Incorrect 40 ms 1260 KB Output isn't correct
6 Incorrect 175 ms 5632 KB Output isn't correct
7 Correct 412 ms 12524 KB Output is correct
8 Correct 294 ms 8940 KB Output is correct
9 Correct 263 ms 8044 KB Output is correct
10 Correct 263 ms 8044 KB Output is correct
11 Incorrect 237 ms 7532 KB Output isn't correct
12 Correct 260 ms 8044 KB Output is correct
13 Incorrect 316 ms 12140 KB Output isn't correct
14 Incorrect 241 ms 7680 KB Output isn't correct
15 Incorrect 305 ms 9580 KB Output isn't correct
16 Incorrect 340 ms 9720 KB Output isn't correct
17 Incorrect 483 ms 16620 KB Output isn't correct
18 Incorrect 340 ms 14572 KB Output isn't correct
19 Runtime error 322 ms 14060 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 307 ms 13112 KB Execution killed with signal 11 (could be triggered by violating memory limits)