# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95077 | 2019-01-27T07:48:16 Z | ae04071 | Collecting Mushrooms (NOI18_collectmushrooms) | C++11 | 32 ms | 23244 KB |
#include <bits/stdc++.h> #define fi first #define se second using namespace std; using pii=pair<int,int>; int n,m,k,d; char str[500010]; vector<int> arr[500010]; vector<pii> ms; inline int gy(int y){return min(max(1,y),n);} inline int gx(int x){return min(max(1,x),m);} int main() { scanf("%d%d%d%d",&n,&m,&d,&k); for(int i=0;i<=n+1;i++) arr[i].resize(m+2,0); for(int i=1;i<=n;i++) { scanf("%s",str+1); for(int j=1;j<=m;j++) { if(str[j]=='M') ms.push_back({i,j}); else if(str[j]=='S') { arr[gy(i-d)][gx(j-d)]+=1; arr[gy(i+d)+1][gx(j-d)]-=1; arr[gy(i-d)][gx(j+d)+1]-=1; arr[gy(i+d)+1][gx(j+d)+1]+=1; } } } for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) { arr[i][j] += arr[i-1][j] + arr[i][j-1] - arr[i-1][j-1]; } int ans=0; for(auto &v:ms) if(arr[v.fi][v.se] >= k) ans++; printf("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 12024 KB | Output is correct |
2 | Correct | 12 ms | 12156 KB | Output is correct |
3 | Correct | 13 ms | 12152 KB | Output is correct |
4 | Correct | 10 ms | 12024 KB | Output is correct |
5 | Correct | 12 ms | 12024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 12024 KB | Output is correct |
2 | Correct | 12 ms | 12156 KB | Output is correct |
3 | Correct | 13 ms | 12152 KB | Output is correct |
4 | Correct | 10 ms | 12024 KB | Output is correct |
5 | Correct | 12 ms | 12024 KB | Output is correct |
6 | Correct | 12 ms | 12024 KB | Output is correct |
7 | Correct | 12 ms | 12024 KB | Output is correct |
8 | Correct | 12 ms | 12152 KB | Output is correct |
9 | Correct | 12 ms | 12072 KB | Output is correct |
10 | Correct | 12 ms | 12024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12024 KB | Output is correct |
2 | Correct | 12 ms | 12024 KB | Output is correct |
3 | Correct | 13 ms | 12280 KB | Output is correct |
4 | Correct | 12 ms | 12152 KB | Output is correct |
5 | Correct | 12 ms | 12152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 13048 KB | Output is correct |
2 | Correct | 14 ms | 13048 KB | Output is correct |
3 | Correct | 15 ms | 13304 KB | Output is correct |
4 | Correct | 14 ms | 13048 KB | Output is correct |
5 | Correct | 14 ms | 13136 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 21100 KB | Output is correct |
2 | Correct | 32 ms | 23144 KB | Output is correct |
3 | Correct | 29 ms | 23244 KB | Output is correct |
4 | Correct | 30 ms | 21152 KB | Output is correct |
5 | Correct | 29 ms | 23108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 12024 KB | Output is correct |
2 | Correct | 12 ms | 12156 KB | Output is correct |
3 | Correct | 13 ms | 12152 KB | Output is correct |
4 | Correct | 10 ms | 12024 KB | Output is correct |
5 | Correct | 12 ms | 12024 KB | Output is correct |
6 | Correct | 12 ms | 12024 KB | Output is correct |
7 | Correct | 12 ms | 12024 KB | Output is correct |
8 | Correct | 12 ms | 12152 KB | Output is correct |
9 | Correct | 12 ms | 12072 KB | Output is correct |
10 | Correct | 12 ms | 12024 KB | Output is correct |
11 | Correct | 12 ms | 12024 KB | Output is correct |
12 | Correct | 12 ms | 12024 KB | Output is correct |
13 | Correct | 13 ms | 12280 KB | Output is correct |
14 | Correct | 12 ms | 12152 KB | Output is correct |
15 | Correct | 12 ms | 12152 KB | Output is correct |
16 | Correct | 14 ms | 13048 KB | Output is correct |
17 | Correct | 14 ms | 13048 KB | Output is correct |
18 | Correct | 15 ms | 13304 KB | Output is correct |
19 | Correct | 14 ms | 13048 KB | Output is correct |
20 | Correct | 14 ms | 13136 KB | Output is correct |
21 | Correct | 26 ms | 21100 KB | Output is correct |
22 | Correct | 32 ms | 23144 KB | Output is correct |
23 | Correct | 29 ms | 23244 KB | Output is correct |
24 | Correct | 30 ms | 21152 KB | Output is correct |
25 | Correct | 29 ms | 23108 KB | Output is correct |
26 | Correct | 26 ms | 15892 KB | Output is correct |
27 | Correct | 21 ms | 16624 KB | Output is correct |
28 | Correct | 22 ms | 15604 KB | Output is correct |
29 | Correct | 19 ms | 15732 KB | Output is correct |
30 | Correct | 25 ms | 16928 KB | Output is correct |