답안 #534195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534195 2022-03-08T02:04:44 Z kebine Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
1271 ms 94752 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
const ll MOD=1e9+7;
using namespace std;
ll N,M,P,Q;
map <pair<ll,ll>,char> a;
map <pair<ll,ll>,ll> pref;

int main(){
  cin>>N>>M>>P>>Q;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=M;j++){
      cin>>a[{i,j}];
    }
  }
  for(int i=1;i<=N;i++){
    for(int j=1;j<=M;j++){
      if(a[{i,j}]=='S'){
        pref[{i,j}]=pref[{i-1,j}]+pref[{i,j-1}]-pref[{i-1,j-1}]+1;
      }
      else{
        pref[{i,j}]=pref[{i-1,j}]+pref[{i,j-1}]-pref[{i-1,j-1}];
      }
    }
  }
  ll catat=0;
  ll e,f,g,h;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=M;j++){
      if(a[{i,j}]=='M'){
        e=max(1ll,i-P);
        f=min(N,i+P);
        g=max(1ll,j-P);
        h=min(M,j+P);
        ll x=pref[{f,h}]-pref[{f,g-1}]-pref[{e-1,h}]+pref[{e-1,g-1}];
        if(x>=Q){
          catat++;
        }
      }
    }
  }
  cout<<catat<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 9 ms 1312 KB Output is correct
3 Correct 9 ms 1484 KB Output is correct
4 Correct 3 ms 552 KB Output is correct
5 Correct 2 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 9 ms 1312 KB Output is correct
3 Correct 9 ms 1484 KB Output is correct
4 Correct 3 ms 552 KB Output is correct
5 Correct 2 ms 672 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 420 KB Output is correct
8 Correct 11 ms 1484 KB Output is correct
9 Correct 4 ms 588 KB Output is correct
10 Correct 1 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 4 ms 676 KB Output is correct
3 Correct 12 ms 1484 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 6 ms 996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 249 ms 25160 KB Output is correct
2 Correct 253 ms 25968 KB Output is correct
3 Correct 326 ms 31852 KB Output is correct
4 Correct 235 ms 26148 KB Output is correct
5 Correct 265 ms 27888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 971 ms 94684 KB Output is correct
2 Correct 1146 ms 94692 KB Output is correct
3 Correct 1271 ms 94640 KB Output is correct
4 Correct 1010 ms 94752 KB Output is correct
5 Correct 1076 ms 94592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 9 ms 1312 KB Output is correct
3 Correct 9 ms 1484 KB Output is correct
4 Correct 3 ms 552 KB Output is correct
5 Correct 2 ms 672 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 420 KB Output is correct
8 Correct 11 ms 1484 KB Output is correct
9 Correct 4 ms 588 KB Output is correct
10 Correct 1 ms 288 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 4 ms 676 KB Output is correct
13 Correct 12 ms 1484 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 6 ms 996 KB Output is correct
16 Correct 249 ms 25160 KB Output is correct
17 Correct 253 ms 25968 KB Output is correct
18 Correct 326 ms 31852 KB Output is correct
19 Correct 235 ms 26148 KB Output is correct
20 Correct 265 ms 27888 KB Output is correct
21 Correct 971 ms 94684 KB Output is correct
22 Correct 1146 ms 94692 KB Output is correct
23 Correct 1271 ms 94640 KB Output is correct
24 Correct 1010 ms 94752 KB Output is correct
25 Correct 1076 ms 94592 KB Output is correct
26 Correct 659 ms 62132 KB Output is correct
27 Correct 752 ms 63500 KB Output is correct
28 Correct 711 ms 63056 KB Output is correct
29 Correct 684 ms 63644 KB Output is correct
30 Correct 674 ms 62808 KB Output is correct