답안 #785510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785510 2023-07-17T09:47:38 Z 12345678 Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
21 ms 18736 KB
#include <bits/stdc++.h>

using namespace std;

int r, c, d, k, ans;
char ch;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>r>>c>>d>>k;
    vector<pair<int, int>> s, m;
    vector<vector<int>> dp(r+5, vector<int> (c+5));
    for (int i=1; i<=r; i++)
    {
        for (int j=1; j<=c; j++)
        {
            cin>>ch;
            if (ch=='M') m.push_back({i, j});
            if (ch=='S')
            {
                dp[max(i-d, 1)][max(j-d, 1)]++;
                dp[max(i-d, 1)][min(j+d+1, c+1)]--;
                dp[min(i+d+1, r+1)][max(j-d, 1)]--;
                dp[min(i+d+1, r+1)][min(j+d+1, c+1)]++;
            }
        }
    }
    for (int i=1; i<=r; i++) for (int j=1; j<=c; j++) dp[i][j]+=dp[i-1][j];
    for (int i=1; i<=r; i++) for (int j=1; j<=c; j++) dp[i][j]+=dp[i][j-1];
    for (auto [x, y]:m) if (dp[x][y]>=k) ans++;
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1236 KB Output is correct
2 Correct 4 ms 1356 KB Output is correct
3 Correct 4 ms 1584 KB Output is correct
4 Correct 3 ms 1264 KB Output is correct
5 Correct 3 ms 1324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 15916 KB Output is correct
2 Correct 16 ms 18736 KB Output is correct
3 Correct 16 ms 18736 KB Output is correct
4 Correct 21 ms 16168 KB Output is correct
5 Correct 16 ms 18700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 5 ms 1236 KB Output is correct
17 Correct 4 ms 1356 KB Output is correct
18 Correct 4 ms 1584 KB Output is correct
19 Correct 3 ms 1264 KB Output is correct
20 Correct 3 ms 1324 KB Output is correct
21 Correct 15 ms 15916 KB Output is correct
22 Correct 16 ms 18736 KB Output is correct
23 Correct 16 ms 18736 KB Output is correct
24 Correct 21 ms 16168 KB Output is correct
25 Correct 16 ms 18700 KB Output is correct
26 Correct 11 ms 5068 KB Output is correct
27 Correct 15 ms 4796 KB Output is correct
28 Correct 12 ms 4096 KB Output is correct
29 Correct 10 ms 4080 KB Output is correct
30 Correct 11 ms 5832 KB Output is correct