# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
333503 | fadi57 | Collecting Mushrooms (NOI18_collectmushrooms) | C++14 | 50 ms | 10604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx=2000;
const int mod= 998244353;
const ll inf=2*1e16+9;
int r,c,d,k;
int main() {
cin>>r>>c>>d>>k;
int a[r+6][c+8];
int pref[r+5][c+5];
for(int i=0;i<=r;i++){
for(int j=0;j<=c;j++){
a[i][j]=pref[i][j] =0;
}
}
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
a[i][j]=pref[i][j] =0;
char x;cin>>x;
if(x=='.'){
a[i][j]=0;
}else if(x=='M'){
a[i][j]=1;
}else{
a[i][j]=2;
}
}
} for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
if(a[i][j]==2){
int uper=max(i-d,1);
int left=max(j-d,1);
// cout<<"hi"<<uper<<" "<<left<<endl;
int right=j+d+1;
int down=i+d+1;
pref[max(i-d,1)][max(j-d,1)]++;
pref[max(i-d,1)][min(j+d+1,c+1)]--;
pref[min(down,r+1)][max(j-d,1)]--;
pref[min(down,r+1)][min(j+d+1,c+1)]++;
}
}
}
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
pref[i][j]+=pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1];
}
}
int ans=0;
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
// cout<<pref[i][j]<<" ";
ans+=(pref[i][j]>=k&&a[i][j]==1);
}
// cout<<endl;
}
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |