# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244261 | 2020-07-03T12:38:18 Z | arnold518 | Collecting Mushrooms (NOI18_collectmushrooms) | C++14 | 50 ms | 7188 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int N, M, D, K; vector<vector<char>> A; vector<vector<int>> S; int query(int y1, int x1, int y2, int x2) { y1=max(y1, 1); x1=max(x1, 1); y2=min(y2, N); x2=min(x2, M); return S[y2][x2]-S[y1-1][x2]-S[y2][x1-1]+S[y1-1][x1-1]; } int main() { int i, j; scanf("%d%d%d%d", &N, &M, &D, &K); A=vector<vector<char>>(N+1, vector<char>(M+1)); S=vector<vector<int>>(N+1, vector<int>(M+1)); for(i=1; i<=N; i++) for(j=1; j<=M; j++) scanf(" %c", &A[i][j]); for(i=1; i<=N; i++) { for(j=1; j<=M; j++) { S[i][j]=S[i-1][j]+S[i][j-1]-S[i-1][j-1]; if(A[i][j]=='S') S[i][j]++; } } int ans=0; for(i=1; i<=N; i++) for(j=1; j<=M; j++) { if(A[i][j]=='M') { if(query(i-D, j-D, i+D, j+D)>=K) ans++; } } printf("%d\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 6 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 1536 KB | Output is correct |
2 | Correct | 19 ms | 1536 KB | Output is correct |
3 | Correct | 22 ms | 1792 KB | Output is correct |
4 | Correct | 19 ms | 1536 KB | Output is correct |
5 | Correct | 20 ms | 1664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 7188 KB | Output is correct |
2 | Correct | 50 ms | 7188 KB | Output is correct |
3 | Correct | 45 ms | 7188 KB | Output is correct |
4 | Correct | 45 ms | 7188 KB | Output is correct |
5 | Correct | 45 ms | 7188 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 6 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 6 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 18 ms | 1536 KB | Output is correct |
17 | Correct | 19 ms | 1536 KB | Output is correct |
18 | Correct | 22 ms | 1792 KB | Output is correct |
19 | Correct | 19 ms | 1536 KB | Output is correct |
20 | Correct | 20 ms | 1664 KB | Output is correct |
21 | Correct | 45 ms | 7188 KB | Output is correct |
22 | Correct | 50 ms | 7188 KB | Output is correct |
23 | Correct | 45 ms | 7188 KB | Output is correct |
24 | Correct | 45 ms | 7188 KB | Output is correct |
25 | Correct | 45 ms | 7188 KB | Output is correct |
26 | Correct | 47 ms | 4984 KB | Output is correct |
27 | Correct | 50 ms | 3328 KB | Output is correct |
28 | Correct | 41 ms | 3328 KB | Output is correct |
29 | Correct | 40 ms | 3328 KB | Output is correct |
30 | Correct | 42 ms | 4480 KB | Output is correct |