Submission #1006013

# Submission time Handle Problem Language Result Execution time Memory
1006013 2024-06-23T10:12:35 Z devariaota Collecting Mushrooms (NOI18_collectmushrooms) C++17
38 / 100
16 ms 13668 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]++;
        nx=i+d+1;
        if(nx<=r) arr[nx][1]--;
        ny=j+d+1;
        if(ny<=c) arr[1][ny]--;
        if(nx<=r && ny<=c) arr[nx][ny]++;
      }
    }
  }
  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 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 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 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2140 KB Output is correct
2 Incorrect 3 ms 2140 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 13660 KB Output is correct
2 Correct 13 ms 13668 KB Output is correct
3 Correct 13 ms 13404 KB Output is correct
4 Correct 16 ms 13404 KB Output is correct
5 Correct 14 ms 13660 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -