답안 #107069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
107069 2019-04-21T16:39:42 Z SOIVIEONE UFO (IZhO14_ufo) C++14
45 / 100
550 ms 28424 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n, m, r, k, p;
	cin >> n >> m >> r >> k >> p;
	int a[n+2][m+2];
	int dp[n + 2][m + 2];
	memset(a, 0, sizeof a);
	memset(dp, 0, sizeof dp);	
	for(int i = 1; i <= n; i ++)
	for(int j = 1; j <= m; j ++)
		cin >> a[i][j];
	while(k --)
	{
		char t;
		int x, y;
		cin >> t >> x >> y;
		if(t == 'W')
		{
			for(int i = 1; i <= r; i ++)
			{
				a[x][i] -= y;
				if(a[x][i] < 0)
					a[x][i] = 0;
			}
		}
		else
		if(t == 'E')
		{
			for(int i = m; i >= m - r + 1; i --)
			{
				a[x][i] -= y;
				if(a[x][i] < 0)
					a[x][i] = 0;
			}
		}
		else
		if(t == 'S')
		{
			for(int i = n; i >= n - r + 1; i --)
			{
				a[i][x] -= y;
				if(a[i][x] < 0)
					a[i][x] = 0;
			}
		}
		else
		{
			for(int i = 1; i <= r; i ++)
			{
				a[i][x] -= y;
				if(a[i][x] < 0)
					a[i][x] = 0;
			}
		}
	}
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= m; j ++)
			dp[i][j] = a[i][j] + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
	int ans = 0;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= m; j ++)
		{
			if(i + p - 1 > n || j + p - 1 > m)
				continue;
			int o = dp[i + p - 1][j + p - 1] - dp[i - 1][j + p - 1] - dp[i + p - 1][j - 1] + dp[i - 1][j - 1];
			umax(ans, o);
		}
	cout << ans;


	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Incorrect 10 ms 544 KB Output isn't correct
5 Incorrect 46 ms 1528 KB Output isn't correct
6 Incorrect 219 ms 7544 KB Output isn't correct
7 Incorrect 488 ms 17800 KB Output isn't correct
8 Correct 326 ms 14200 KB Output is correct
9 Incorrect 286 ms 12408 KB Output isn't correct
10 Correct 318 ms 13176 KB Output is correct
11 Runtime error 181 ms 21368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Correct 297 ms 13304 KB Output is correct
13 Correct 359 ms 14216 KB Output is correct
14 Correct 321 ms 13048 KB Output is correct
15 Incorrect 320 ms 14840 KB Output isn't correct
16 Correct 365 ms 15352 KB Output is correct
17 Incorrect 550 ms 18568 KB Output isn't correct
18 Correct 371 ms 14200 KB Output is correct
19 Runtime error 177 ms 24540 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Correct 406 ms 28424 KB Output is correct