답안 #147393

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147393 2019-08-29T12:28:24 Z JovanK26 Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
19 ms 5288 KB
#include <bits/stdc++.h>

using namespace std;
int rez=0;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,d,k;
    cin >> n >> m >> d >> k;
    char mat1[n][m];
    int mat2[n][m];
    int f[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin >> mat1[i][j];
            if(mat1[i][j]=='S')mat2[i][j]=1;
            else
            {
                mat2[i][j]=0;
            }
        }
    }
    f[0][0]=mat2[0][0];
    for(int i=1;i<n;i++)
    {
        f[i][0]=f[i-1][0]+mat2[i][0];
    }
    for(int i=1;i<m;i++)
    {
        f[0][i]=f[0][i-1]+mat2[0][i];
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+mat2[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(mat1[i][j]=='M')
            {
                int temp=0;
                int i1=max(0,i-d);
                int j1=max(0,j-d);
                int i2=min(n-1,i+d);
                int j2=min(m-1,j+d);
                temp+=f[i2][j2];
                if(i1-1>=0)temp-=f[i1-1][j2];
                if(j1-1>=0)temp-=f[i2][j1-1];
                if(i1-1>=0 && j1-1>=0)temp+=f[i1-1][j1-1];
                if(temp>=k)
                {
                    rez++;
                }
            }
        }
    }
    cout << rez;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2040 KB Output is correct
2 Correct 7 ms 2168 KB Output is correct
3 Correct 9 ms 2808 KB Output is correct
4 Correct 7 ms 2296 KB Output is correct
5 Correct 8 ms 2472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 4728 KB Output is correct
2 Correct 15 ms 4728 KB Output is correct
3 Correct 16 ms 4728 KB Output is correct
4 Correct 19 ms 4788 KB Output is correct
5 Correct 18 ms 4728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 248 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 7 ms 2040 KB Output is correct
17 Correct 7 ms 2168 KB Output is correct
18 Correct 9 ms 2808 KB Output is correct
19 Correct 7 ms 2296 KB Output is correct
20 Correct 8 ms 2472 KB Output is correct
21 Correct 17 ms 4728 KB Output is correct
22 Correct 15 ms 4728 KB Output is correct
23 Correct 16 ms 4728 KB Output is correct
24 Correct 19 ms 4788 KB Output is correct
25 Correct 18 ms 4728 KB Output is correct
26 Correct 18 ms 5148 KB Output is correct
27 Correct 17 ms 5240 KB Output is correct
28 Correct 18 ms 5112 KB Output is correct
29 Correct 17 ms 5288 KB Output is correct
30 Correct 17 ms 5112 KB Output is correct