Submission #1006018

# Submission time Handle Problem Language Result Execution time Memory
1006018 2024-06-23T10:17:32 Z christinelynn Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
17 ms 13664 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define repp(i,x,n) for(int i=x;i<=n;i++)
#define repo(i,x,n) for(int i=x;i>=n;i--)
#define cy cout<<"Yes"<<endl
#define cn cout<<"No"<<endl
#define r0 return 0
#define fi first
#define se second
#define liow ios_base::sync_with_stdio(false);cin.tie(NULL)
#define jelek cout<<"jelek"<<endl
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define pi pair<pair<int,int>,pair<int,int>>
#define fl fflush(stdout)
using namespace std;
const int mod=1e9+7,maxn=1e6+5,N=(1<<17),INF=1e18;

void solve(){
  int r,c,d,s;cin>>r>>c>>d>>s;
  char a[r+2][c+2];
  int arr[r+2][c+2];
  memset(arr,0,sizeof arr);
  repp(i,1,r){
    repp(j,1,c){
      cin>>a[i][j];
      if(a[i][j]=='S'){
        int nx=i-d,ny=j-d;
        if(nx<1) nx=1;
        if(ny<1) ny=1;
        arr[nx][ny]++;
        int rx=i+d+1;
        if(rx<=r) arr[rx][ny]--;
        int ry=j+d+1;
        if(ry<=c) arr[nx][ry]--;
        if(rx<=r && ry<=c) arr[rx][ry]++;
      }
    }
  }
  repp(i,1,r){
    repp(j,1,c){
      arr[i][j]=arr[i][j]+arr[i-1][j]+arr[i][j-1]-arr[i-1][j-1];
    }
  }
  int ans=0;
  repp(i,1,r){
    repp(j,1,c){
      if(a[i][j]=='M'){
        if(arr[i][j]>=s) ans++;
      }
    }
  }
  cout<<ans;
}

signed main() {
    liow;
    int t=1;
//  cin>>t;
    while(t--){
      solve();
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 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 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 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 0 ms 348 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 5 ms 2136 KB Output is correct
2 Correct 3 ms 2140 KB Output is correct
3 Correct 4 ms 2652 KB Output is correct
4 Correct 4 ms 2140 KB Output is correct
5 Correct 5 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 13608 KB Output is correct
2 Correct 17 ms 13664 KB Output is correct
3 Correct 13 ms 13660 KB Output is correct
4 Correct 15 ms 13472 KB Output is correct
5 Correct 15 ms 13664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 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 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 5 ms 2136 KB Output is correct
17 Correct 3 ms 2140 KB Output is correct
18 Correct 4 ms 2652 KB Output is correct
19 Correct 4 ms 2140 KB Output is correct
20 Correct 5 ms 2140 KB Output is correct
21 Correct 16 ms 13608 KB Output is correct
22 Correct 17 ms 13664 KB Output is correct
23 Correct 13 ms 13660 KB Output is correct
24 Correct 15 ms 13472 KB Output is correct
25 Correct 15 ms 13664 KB Output is correct
26 Correct 9 ms 4956 KB Output is correct
27 Correct 9 ms 4804 KB Output is correct
28 Correct 10 ms 5024 KB Output is correct
29 Correct 9 ms 4956 KB Output is correct
30 Correct 11 ms 4952 KB Output is correct