Submission #880288

# Submission time Handle Problem Language Result Execution time Memory
880288 2023-11-29T06:08:53 Z The_Samurai UFO (IZhO14_ufo) C++17
35 / 100
2000 ms 9676 KB
// 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
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 11 ms 672 KB Output is correct
6 Correct 47 ms 2392 KB Output is correct
7 Execution timed out 2055 ms 9676 KB Time limit exceeded
8 Execution timed out 2058 ms 6676 KB Time limit exceeded
9 Execution timed out 2043 ms 6816 KB Time limit exceeded
10 Execution timed out 2032 ms 6800 KB Time limit exceeded
11 Execution timed out 2036 ms 6280 KB Time limit exceeded
12 Execution timed out 2033 ms 7112 KB Time limit exceeded
13 Execution timed out 2035 ms 7256 KB Time limit exceeded
14 Correct 1695 ms 6796 KB Output is correct
15 Execution timed out 2065 ms 7448 KB Time limit exceeded
16 Execution timed out 2059 ms 6020 KB Time limit exceeded
17 Execution timed out 2027 ms 7672 KB Time limit exceeded
18 Execution timed out 2003 ms 8792 KB Time limit exceeded
19 Execution timed out 2012 ms 6048 KB Time limit exceeded
20 Execution timed out 2058 ms 8284 KB Time limit exceeded