# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
345328 | bachaquer | UFO (IZhO14_ufo) | C++14 | 2083 ms | 8948 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
ll n, m, r, k, p;
cin >> n >> m >> r >> k >> p;
ll l[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> l[i][j];
}
}
char c;
int x, h;
for (int t = 0; t < k; t++) {
cin >> c >> x >> h;
ll ups = 0;
if (c == 'W') {
for (int j = 0; j < m && ups < r; j++) {
if (l[x - 1][j] >= h) {
l[x - 1][j]--;
ups++;
}
}
}
else if (c == 'N') {
for (int i = 0; i < n && ups < r; i++) {
if (l[i][x - 1] >= h) {
l[i][x - 1]--;
ups++;
}
}
}
else if (c == 'E') {
for (int j = m - 1; j >= 0 && ups < r; j--) {
if (l[x - 1][j] >= h) {
l[x - 1][j]--;
ups++;
}
}
}
else if (c == 'S') {
for (int i = n - 1; i >= 0 && ups < r; i--) {
if (l[i][x - 1] >= h) {
l[i][x - 1]--;
ups++;
}
}
}
}
ll mx = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ll sum = 0;
if (p > j + 1 || p > i + 1) continue;
bool br = false;
for (int up = i; up >= i - p + 1; up--) {
for (int left = j; left >= j - p + 1; left--) {
sum += l[up][left];
if (l[up][left] == 0) {
br = true;
break;
}
}
if (br) break;
}
if (br) continue;
mx = max(sum, mx);
}
}
cout << mx;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |