답안 #321046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321046 2020-11-10T17:40:38 Z arujbansal Collecting Mushrooms (NOI18_collectmushrooms) C++17
19 / 100
26 ms 8172 KB
#include <bits/stdc++.h>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int N = 1e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;

signed main() {
    FAST_IO;
#ifdef arujbansal_local
    setIO("input.txt", "output.txt");
#endif

    int n, m, d, k;
    cin >> n >> m >> d >> k;

    vvi dp(n + 2, vi(m + 2, 0));

    char grid[n + 2][m + 2];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> grid[i][j];
            if (grid[i][j] != 'S') continue;

            dp[max(1, i - d)][max(1, j - d)]++;
            dp[min(n, i + d) + 1][max(1, j - d)]--;

            dp[max(1, i - d)][min(m + 1, j + d) + 1]--;
            dp[min(n, i + d) + 1][min(m + 1, j + d) + 1]++;
        }
    }

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            dp[i][j] += dp[i - 1][j];

    int ans = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i][j] += dp[i][j - 1];
            ans += (grid[i][j] == 'M' && dp[i][j] >= k);
        }
    }

    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1260 KB Output is correct
2 Runtime error 7 ms 2836 KB Execution killed with signal 6 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 8172 KB Output is correct
2 Correct 15 ms 8172 KB Output is correct
3 Correct 15 ms 8172 KB Output is correct
4 Correct 26 ms 8172 KB Output is correct
5 Correct 18 ms 8172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -