# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
880288 | The_Samurai | UFO (IZhO14_ufo) | C++17 | 2065 ms | 9676 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// I stand with PALESTINE
//#pragma GCC optimize("Ofast,O3")
//#pragma GCC target("avx,avx2")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
void solve() {
int n, m, r, q, p;
cin >> n >> m >> r >> q >> p;
vector<vector<int>> a(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) cin >> a[i][j];
}
while (q--) {
char op;
int i, v;
cin >> op >> i >> v;
i--;
if (op == 'W') {
for (int j = 0, c = 0; j < m and c < r; j++) {
if (a[i][j] >= v) {
a[i][j]--;
c++;
}
}
} else if (op == 'E') {
for (int j = m - 1, c = 0; j >= 0 and c < r; j--) {
if (a[i][j] >= v) {
a[i][j]--;
c++;
}
}
} else if (op == 'N') {
for (int j = 0, c = 0; j < n and c < r; j++) {
if (a[j][i] >= v) {
a[j][i]--;
c++;
}
}
} else {
for (int j = n - 1, c = 0; j >= 0 and c < r; j--) {
if (a[j][i] >= v) {
a[j][i]--;
c++;
}
}
}
}
int ans = 0;
for (int i = 0; i <= n - p; i++) {
for (int j = 0; j <= m - p; j++) {
int sum = 0;
for (int x = i; x < i + p; x++) {
for (int y = j; y < j + p; y++) {
sum += a[x][y];
}
}
ans = max(ans, sum);
}
}
cout << ans;
}
int main() {
cin.tie(0)->sync_with_stdio(false);
#ifdef sunnatov
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int q = 1;
// cin >> q;
while (q--) {
solve();
cout << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |