답안 #533742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533742 2022-03-07T05:18:36 Z devariaota Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
29 ms 13764 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef double dbl;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef map<ll, ll> mll;
typedef pair<string, ll> psl;
typedef map<string, ll> msl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef deque<ll> deq;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqm;
typedef priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> dij;
typedef priority_queue<ll> pq;
typedef string str;
const ll mod=1e9+7;
const ll maxn=1e5+1;
ll gcd(ll a, ll b) {
    return a==0 ? b : gcd(a, b%a);
}
ll lcm(ll a, ll b) {
    ll ans=a*b;
    ans=ans/(gcd(a, b));
    return ans;
}
#define ihacoy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define dh << endl;
#define co cout <<
#define udh cout << endl;
#define spa << " ";
#define ci cin >>
#define fi first
#define se second
#define sp << " " <<
#define tes while(t--)
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
#define gre greater<ll>()
#define sip return 0
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
int r, c, d, k, ans;
int main() {
    ihacoy
    ci r >> c >> d >> k;
    vector<vector<char>> grid(r+1, vector<char>(c+1));
    vector<vi> area(r+2, vi(c+2));
    vector<pii> mush;
    for(int i=1; i<=r; i++) {
        for(int j=1; j<=c; j++) {
            ci grid[i][j];
            if(grid[i][j]=='M') {
                mush.pb({i, j});
            } else if(grid[i][j]=='S') {
                area[max(1, i-d)][max(1, j-d)]++;
                area[max(1, i-d)][min(c+1, j+d+1)]--;
                area[min(r+1,i+d+1)][max(1, j-d)]--;
                area[min(r+1, i+d+1)][min(c+1, j+d+1)]++;
            }
        }
    }
    for(int i=1; i<=c; i++) {
        for(int j=1; j<=r; j++) {
            area[j][i]=area[j-1][i]+area[j][i];
        }
    }
    for(int i=1; i<=r; i++) {
        for(int j=1; j<=c; j++) {
            area[i][j]=area[i][j-1]+area[i][j];
        }
    }
    for(auto it : mush) {
        if(area[it.fi][it.se]>=k) ans++;
    }
    co ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1228 KB Output is correct
2 Correct 5 ms 1480 KB Output is correct
3 Correct 5 ms 1732 KB Output is correct
4 Correct 5 ms 1572 KB Output is correct
5 Correct 5 ms 1616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 10484 KB Output is correct
2 Correct 19 ms 13748 KB Output is correct
3 Correct 19 ms 13740 KB Output is correct
4 Correct 29 ms 11224 KB Output is correct
5 Correct 24 ms 13764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 584 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 4 ms 1228 KB Output is correct
17 Correct 5 ms 1480 KB Output is correct
18 Correct 5 ms 1732 KB Output is correct
19 Correct 5 ms 1572 KB Output is correct
20 Correct 5 ms 1616 KB Output is correct
21 Correct 20 ms 10484 KB Output is correct
22 Correct 19 ms 13748 KB Output is correct
23 Correct 19 ms 13740 KB Output is correct
24 Correct 29 ms 11224 KB Output is correct
25 Correct 24 ms 13764 KB Output is correct
26 Correct 20 ms 5952 KB Output is correct
27 Correct 15 ms 5300 KB Output is correct
28 Correct 18 ms 4320 KB Output is correct
29 Correct 16 ms 4424 KB Output is correct
30 Correct 19 ms 6692 KB Output is correct