Submission #880288

#TimeUsernameProblemLanguageResultExecution timeMemory
880288The_SamuraiUFO (IZhO14_ufo)C++17
35 / 100
2065 ms9676 KiB
// 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 timeMemoryGrader output
Fetching results...