Submission #684008

# Submission time Handle Problem Language Result Execution time Memory
684008 2023-01-20T03:33:01 Z pragmatist UFO (IZhO14_ufo) C++17
15 / 100
2000 ms 8148 KB
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/

#include<bits/stdc++.h>
 
#define ld long double
#define sz(v) (int)v.size()
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define nl "\n"

using namespace std;
using pii = pair<int, int>;

const int N = (int)1e2 + 7; // make sure this is right
const int M = (int)1e3 + 7;
const int inf = (int)2e9 + 7;
const ll INF = (ll)3e18 + 7; 
const double PI = acos(-1);
ll MOD = (ll)1e9 + 7; // make sure this is right

bool bit(int x, int i) {
	return x >> i & 1;
}

int sum(int x, int y) {
	x += y;
	if(x >= MOD) x -= MOD;
	return x;
}

pii dir[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int n, m, r, q, p;

void solve() {
	cin >> n >> m >> r >> q >> p;
	int a[n + 1][m + 1];
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			cin >> a[i][j];
		}
	}
	while(q--) {
		char tp;
		cin >> tp;
		int x, y;
		cin >> x >> y;
		if(tp == 'W') {
			for(int i = 1, cnt = r; i <= m && cnt; ++i) {
				if(a[x][i] >= y) {
					a[x][i]--;
					cnt--;
				}
			}
		}
		if(tp == 'E') {
			for(int i = m, cnt = r; i >= 1 && cnt; --i) {
				if(a[x][i] >= y) {
					a[x][i]--;
					cnt--;
				}
			}
		}
		if(tp == 'N') {
			for(int i = 1, cnt = r; i <= n && cnt; ++i) {
				if(a[i][x] >= y) {
					a[i][x]--;
					cnt--;
				}
			}
		}
		if(tp == 'S') {
			for(int i = n, cnt = 1; i >= 1 && cnt; --i) {
				if(a[i][x] >= y) {
					a[i][x]--;
					cnt--;
				}
			}
		}
	}
	int ans = 0;
	for(int i = 1; i <= n - p + 1; ++i) {
		for(int j = 1; j <= m - p + 1; ++j) {
			int cur = 0;
			for(int ii = i; ii <= i + p - 1; ++ii) {
				for(int jj = j; jj <= j + p - 1; ++jj) {
					cur += a[ii][jj];
				}
			}
			ans = max(ans, cur);
		}
	}
	cout << ans;
}

signed main() {	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen("g.in", "r", stdin);
//	freopen("g.out", "w", stdout);
	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; ++i) {
	 	//cout << "Case #" << i << ": ";
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Incorrect 4 ms 468 KB Output isn't correct
5 Incorrect 14 ms 596 KB Output isn't correct
6 Incorrect 67 ms 2248 KB Output isn't correct
7 Execution timed out 2071 ms 4728 KB Time limit exceeded
8 Execution timed out 2050 ms 4664 KB Time limit exceeded
9 Execution timed out 2061 ms 4920 KB Time limit exceeded
10 Execution timed out 2080 ms 5236 KB Time limit exceeded
11 Execution timed out 2045 ms 4776 KB Time limit exceeded
12 Execution timed out 2074 ms 5416 KB Time limit exceeded
13 Execution timed out 2081 ms 5624 KB Time limit exceeded
14 Correct 1101 ms 5428 KB Output is correct
15 Execution timed out 2089 ms 5364 KB Time limit exceeded
16 Execution timed out 2078 ms 4660 KB Time limit exceeded
17 Execution timed out 2059 ms 5888 KB Time limit exceeded
18 Execution timed out 2074 ms 4180 KB Time limit exceeded
19 Execution timed out 2069 ms 5244 KB Time limit exceeded
20 Execution timed out 2081 ms 8148 KB Time limit exceeded