Submission #1015522

# Submission time Handle Problem Language Result Execution time Memory
1015522 2024-07-06T13:11:48 Z ag_1204 Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
14 ms 17632 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll r,c,d,k; cin>>r>>c>>d>>k;
    ll grid[r+1][c+1];
    for (ll i=0;i<=r;i++) {
        grid[i][0]=0;
    }
    for (ll i=0;i<=c;i++) {
        grid[0][i]=0;
    }
    vector<pair<ll,ll>> mush;
    for (ll i=1;i<=r;i++) {
        string s; cin>>s;
        for (ll j=1;j<=c;j++) {
            if (s[j-1]=='M') {
                pair<ll,ll> p;
                p.first=i; p.second=j;
                mush.push_back(p);
            }
            grid[i][j]=grid[i-1][j]+grid[i][j-1]-grid[i-1][j-1];
            if (s[j-1]=='S') grid[i][j]++;
        }
    }
    ll ans=0;
    for (auto p:mush) {
        ll x1=p.first-d,x2=p.first+d,y1=p.second-d,y2=p.second+d;
        x1=max(x1-1,(ll) 0); x2=min(x2,r);
        y1=max(y1-1,(ll) 0); y2=min(y2,c);
        ll count=grid[x2][y2]-grid[x1][y2]-grid[x2][y1]+grid[x1][y1];
        if (count>=k) {
            ans++;
        }
    }
    cout<<ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2140 KB Output is correct
2 Correct 2 ms 2168 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2140 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 13796 KB Output is correct
2 Correct 14 ms 17568 KB Output is correct
3 Correct 13 ms 17632 KB Output is correct
4 Correct 10 ms 14984 KB Output is correct
5 Correct 14 ms 17628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 2 ms 2140 KB Output is correct
17 Correct 2 ms 2168 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2140 KB Output is correct
20 Correct 2 ms 2396 KB Output is correct
21 Correct 9 ms 13796 KB Output is correct
22 Correct 14 ms 17568 KB Output is correct
23 Correct 13 ms 17632 KB Output is correct
24 Correct 10 ms 14984 KB Output is correct
25 Correct 14 ms 17628 KB Output is correct
26 Correct 8 ms 6868 KB Output is correct
27 Correct 8 ms 9936 KB Output is correct
28 Correct 7 ms 6752 KB Output is correct
29 Correct 6 ms 7108 KB Output is correct
30 Correct 8 ms 9736 KB Output is correct