# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
504953 | akshtsinghania | Collecting Mushrooms (NOI18_collectmushrooms) | C++14 | 14 ms | 19352 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
// the argument is the input filename without the extension
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
void solve(){
int r,c,d,k;
cin>>r>>c>>d>>k;
vector<vector<int>> g(r+1,vector<int>(c+1));
vector<vector<char>> ga(r+1,vector<char>(c+1));
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
char a;
cin>>a;
ga[i][j]=a;
//if(a=='M')g[i][j]+=0;
if(a=='S'){
int start_x=max((int)1,i-d),start_y=max((int)1,j-d);
int end_x=max((int)r,i+d),end_y=max((int)r,j+d);
g[start_x][start_y]++;
g[end_x][end_y]++;
g[start_x][end_y]--;
g[end_x][start_y]--;
}
}
}
int ans=0;
vector<vector<int>> prefix(r+1,vector<int>(c+1));
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
prefix[i][j]=g[i][j]
+prefix[i-1][j]
+prefix[i][j-1]
-prefix[i-1][j-1];
if(ga[i][j]=='M'&&prefix[i][j]>=k)ans++;
//cout<<prefix[i][j]<<" ";
}
//cout<<endl;
}
cout<<ans<<endl;
}
signed main(){
cin.tie(NULL);
cout.tie(NULL);
//setIO("paintbarn");
ios_base::sync_with_stdio(NULL);
int t=1;
//cin>>t;
while(t--)solve();
return 0;
}
/*
5 5 1 1
....M
.M...
..S..
.S...
...M.
*/
컴파일 시 표준 에러 (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... |