답안 #331377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
331377 2020-11-28T08:23:37 Z Sho10 Collecting Mushrooms (NOI18_collectmushrooms) C++14
0 / 100
20 ms 8812 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,d,k;
int32_t main(){
CODE_START
cin>>n>>m;
ll sum[n+5][m+5];
char a[n+5][m+5];
for(ll i=1;i<=n;i++)
{
    for(ll j=1;j<=m;j++)
    {
        sum[i][j]=0;
    }
}
for(ll i=1;i<=n;i++)
{
    for(ll j=1;j<=m;j++)
    {
        char c;
        cin>>a[i][j];
        c=a[i][j];
        if(c=='S'){
            ll x,y;
            x=max(1ll,i-d);
            y=max(1ll,j-d);
            ll xx,yy;
            xx=min(1+n,1+i+d);
            yy=min(1+m,1+j+d);
            sum[x][y]++;
            sum[x][yy]--;
            sum[xx][y]--;
            sum[xx][yy]++;

        }
    }
}
for(ll i=1;i<=n;i++)
{
    for(ll j=1;j<=m;j++)
    {
        sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
    }
}
ll ans=0;
for(ll i=1;i<=n;i++)
{
    for(ll j=1;j<=m;j++)
    {
        if(sum[i][j]>=k&&a[i][j]=='M'){
            ans++;
        }
    }
}
rc(ans);
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 2284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 8812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 492 KB Output isn't correct
4 Halted 0 ms 0 KB -