이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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=nx+2*d+1;
if(nx<=r) arr[nx][1]--;
ny=ny+2*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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |