Submission #182429

# Submission time Handle Problem Language Result Execution time Memory
182429 2020-01-09T21:09:28 Z duttaditya18 Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
72 ms 10468 KB
#include <bits/stdc++.h>

using namespace std;
#define fi first
#define se second

int main(void)
{
    int r, c, d, k; cin >> r >> c >> d >> k;

    vector<pair<int, int>> v;
    vector<pair<int, int>> s;

    char x;
    int a[r + 2][c + 2] = {};

    for(int i = 1; i <= r; i++)
    {
        for(int j = 1; j <= c; j++)
        {
            cin >> x;
            if(x == 'M') v.push_back(make_pair(i, j));
            if(x == 'S')
            {
                a[max(1, i - d)][max(1, j - d)]++;
                a[min(r + 1, i + d + 1)][max(1, j - d)]--;
                a[max(1, i - d)][min(c + 1, j + d + 1)]--;
                a[min(r + 1, i + d + 1)][min(c + 1, j + d + 1)]++;
            }
        }
    }


    for(int i = 1; i <= r; i++)
        for(int j = 1; j <= c; j++)
            a[i][j] += a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1];

    // for(int i = 1; i <= r + 1; i++) { for(int j = 1; j <= c + 1; j++) cout << a[i][j] << " "; cout << endl; }


    int ans = 0;
    for(auto u : v) if(a[u.fi][u.se] >= k) ans++;
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1144 KB Output is correct
2 Correct 23 ms 1144 KB Output is correct
3 Correct 27 ms 1272 KB Output is correct
4 Correct 23 ms 1272 KB Output is correct
5 Correct 25 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 8424 KB Output is correct
2 Correct 67 ms 10468 KB Output is correct
3 Correct 70 ms 10468 KB Output is correct
4 Correct 66 ms 8412 KB Output is correct
5 Correct 72 ms 10436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 1 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 632 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 22 ms 1144 KB Output is correct
17 Correct 23 ms 1144 KB Output is correct
18 Correct 27 ms 1272 KB Output is correct
19 Correct 23 ms 1272 KB Output is correct
20 Correct 25 ms 1144 KB Output is correct
21 Correct 63 ms 8424 KB Output is correct
22 Correct 67 ms 10468 KB Output is correct
23 Correct 70 ms 10468 KB Output is correct
24 Correct 66 ms 8412 KB Output is correct
25 Correct 72 ms 10436 KB Output is correct
26 Correct 58 ms 3568 KB Output is correct
27 Correct 61 ms 4968 KB Output is correct
28 Correct 67 ms 3952 KB Output is correct
29 Correct 62 ms 4080 KB Output is correct
30 Correct 62 ms 4972 KB Output is correct