Submission #37922

#TimeUsernameProblemLanguageResultExecution timeMemory
37922TalantUFO (IZhO14_ufo)C++14
35 / 100
2000 ms9708 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define OK puts("OK"); #define pb push_back #define mk make_pair using namespace std; typedef long long ll; const int inf = (int)1e9 + 7; const int N = (int)1e6 + 7; int n,m,r,k,p; int mx = 0; int main () { cin >> n >> m >> r >> k >> 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 (k --) { char ch; int l,bl,cnt = 0; cin >> ch >> l >> bl; if (ch == 'N') { cnt = 0; for (int i = 1; i <= n; i ++) { if (a[i][l] >= bl) a[i][l] --,cnt ++; if (cnt == r) break; } } else if (ch == 'W') { cnt = 0; for (int i = 1; i <= m; i ++) { if (a[l][i] >= bl) a[l][i] --,cnt ++; if (cnt == r) break; } } else if (ch == 'E') { cnt = 0; for (int i = m; i >= 1; i --) { if (a[l][i] >= bl) a[l][i] --,cnt ++; if (cnt == r) break; } } else { cnt = 0; for (int i = n; i >= 1; i --) { if (a[i][l] >= bl) a[i][l] --,cnt ++; if (cnt == r) break; } } } for (int i = 1; i <= n; i ++) for (int j = 2; j <= m; j ++) a[i][j] += a[i][j - 1]; for (int i = 2; i <= n; i ++) for (int j = 1; j <= m; j ++) a[i][j] += a[i - 1][j]; for (int i = 1; i <= n; i ++) a[i][0] = 0; for (int j = 0; j <= m; j ++) a[0][j] = 0; for (int i = p; i <= n; i ++) for (int j = p; j <= m; j ++) { mx = max(mx,a[i][j] - a[i - p][j] - a[i][j - p] + a[i - p][j - p]); } cout << mx << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...