답안 #154492

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154492 2019-09-22T07:36:36 Z srvlt UFO (IZhO14_ufo) C++14
35 / 100
2000 ms 9976 KB
#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();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 7 ms 504 KB Output is correct
5 Correct 21 ms 1144 KB Output is correct
6 Correct 89 ms 2860 KB Output is correct
7 Execution timed out 2036 ms 4980 KB Time limit exceeded
8 Execution timed out 2021 ms 5092 KB Time limit exceeded
9 Execution timed out 2055 ms 5328 KB Time limit exceeded
10 Execution timed out 2064 ms 5348 KB Time limit exceeded
11 Execution timed out 2027 ms 5068 KB Time limit exceeded
12 Execution timed out 2051 ms 5472 KB Time limit exceeded
13 Execution timed out 2056 ms 8336 KB Time limit exceeded
14 Correct 1998 ms 5080 KB Output is correct
15 Execution timed out 2041 ms 5232 KB Time limit exceeded
16 Execution timed out 2047 ms 5200 KB Time limit exceeded
17 Execution timed out 2058 ms 8248 KB Time limit exceeded
18 Execution timed out 2036 ms 9976 KB Time limit exceeded
19 Execution timed out 2052 ms 5476 KB Time limit exceeded
20 Execution timed out 2041 ms 8184 KB Time limit exceeded