답안 #161130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161130 2019-10-31T15:34:12 Z kimbj0709 Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
20 ms 4600 KB
#include <bits/stdc++.h>
using namespace std;
vector<vector<char> > board;
vector<vector<int> > psum;
int n,m;
int sum(int a,int b){
    if(a<0 || b<0)return 0;
    a=min(a,n-1);b=min(b,m-1);
    return psum[a][b];
}
int sum(int a,int b,int c,int d){
    return sum(c,d)-sum(a-1,d)-sum(c,b-1)+sum(a-1,b-1);
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k,d;
    cin >> n >> m >> d >> k;
    board.resize(n);
    psum.resize(n);
    for(int i=0;i<n;i++){
        board[i].resize(m);
        psum[i].resize(m);
    }
    string str;
    for(int i=0;i<n;i++){
        cin >> str;
        for(int j=0;j<m;j++){
            board[i][j]=str[j];
            psum[i][j]=sum(i-1,j)+sum(i,j-1)-sum(i-1,j-1);
            psum[i][j]+=board[i][j]=='S';
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(board[i][j]=='M'){
                ans+=sum(i-d,j-d,i+d,j+d)>=k;
            }
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 372 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 372 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 424 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1400 KB Output is correct
2 Correct 7 ms 1656 KB Output is correct
3 Correct 7 ms 1656 KB Output is correct
4 Correct 6 ms 1528 KB Output is correct
5 Correct 7 ms 1528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 3596 KB Output is correct
2 Correct 17 ms 3588 KB Output is correct
3 Correct 16 ms 3596 KB Output is correct
4 Correct 15 ms 3596 KB Output is correct
5 Correct 17 ms 3588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 372 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 424 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 6 ms 1400 KB Output is correct
17 Correct 7 ms 1656 KB Output is correct
18 Correct 7 ms 1656 KB Output is correct
19 Correct 6 ms 1528 KB Output is correct
20 Correct 7 ms 1528 KB Output is correct
21 Correct 14 ms 3596 KB Output is correct
22 Correct 17 ms 3588 KB Output is correct
23 Correct 16 ms 3596 KB Output is correct
24 Correct 15 ms 3596 KB Output is correct
25 Correct 17 ms 3588 KB Output is correct
26 Correct 20 ms 4600 KB Output is correct
27 Correct 15 ms 2936 KB Output is correct
28 Correct 14 ms 2936 KB Output is correct
29 Correct 14 ms 2936 KB Output is correct
30 Correct 19 ms 4216 KB Output is correct