| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 742812 | Fnzx | Collecting Mushrooms (NOI18_collectmushrooms) | C++17 | 21 ms | 10180 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
using pii = pair<ll , ll> ;
using i3 = tuple<ll , ll , ll> ;
const int N = 1001;
const int MOD = 1e9+7 ;
int n , m , d , k , ans;
int G[N][N] ;
vector<pii> mushroom ;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m >> d >> k ;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char x ; cin >> x ;
if(x == 'S'){
G[i][j]++ ;
}
else if(x == 'M'){
mushroom.push_back({i , j});
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
G[i][j] += G[i-1][j] + G[i][j-1] - G[i-1][j-1] ;
}
}
for(int i=0;i<mushroom.size();i++){
int uy = mushroom[i].first , ux = mushroom[i].second ;
int x1 = max(1 , ux - d) , y1 = max(1 , uy - d) ;
int x2 = min(m , ux + d) , y2 = min(n , uy + d) ;
int sum = G[y2][x2] - G[y1 - 1][x2] - G[y2][x1 - 1] + G[y1 - 1][x1 - 1] ;
if(sum >= k){
ans++;
}
}
cout << ans ;
}
Compilation message (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... | ||||
