Submission #154492

#TimeUsernameProblemLanguageResultExecution timeMemory
154492srvltUFO (IZhO14_ufo)C++14
35 / 100
2064 ms9976 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("sse2,avx") #include <bits/stdc++.h> #define ll long long #define db long double #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define fi first #define se second #define mp make_pair #define endl "\n" //#define int long long using namespace std; void dout() { cerr << endl; } template <typename Head, typename... Tail> void dout(Head H, Tail... T) { cerr << H << ' '; dout(T...); } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m, r, k, p; void solve(int tc) { cin >> n >> m >> r >> k >> p; vector <vector <int> > g(n, vector <int>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> g[i][j]; } } for (int i = 0; i < k; i++) { char c; int x, y; cin >> c >> x >> y; x--; int cur = r; if (c == 'W') { for (int j = 0; j < m; j++) { if (g[x][j] >= y) { cur--; g[x][j]--; } if (cur == 0) { break; } } } else if (c == 'E') { for (int j = m - 1; j >= 0; j--) { if (g[x][j] >= y) { cur--; g[x][j]--; } if (cur == 0) { break; } } } else if (c == 'N') { for (int j = 0; j < n; j++) { if (g[j][x] >= y) { cur--; g[j][x]--; } if (cur == 0) { break; } } } else { for (int j = n - 1; j >= 0; j--) { if (g[j][x] >= y) { cur--; g[j][x]--; } if (cur == 0) { break; } } } } int res = 0; for (int i = 0; i < n - p + 1; i++) { for (int j = 0; j < m - p + 1; j++) { int tmp = 0; for (int h = i; h < i + p; h++) { for (int l = j; l < j + p; l++) { tmp += g[h][l]; } } res = max(res, tmp); } } cout << res; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int tc = 1; // cin >> tc; for (int i = 0; i < tc; i++) { solve(i); // cleanup(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...