Submission #1106699

# Submission time Handle Problem Language Result Execution time Memory
1106699 2024-10-30T22:12:05 Z vjudge1 Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
14 ms 10440 KB
#include <bits/stdc++.h>
#define sts(v) svble_sort(v.BE, v.E)
#define Rsts(v) svble_sort(v.rBE, v.rE)
#define rev(v) reverse(v.BE, v.E)
#define BE begin()
#define rBE rbegin()
#define E end()
#define rE rend()
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second

using namespace std;
using ll = long long;

const int MAXN = 1e5 + 1;
const int MOD = 1e9 + 7;

int n, m, D, K;
vector<vector<int>> v;

int new_cord(int a, int b){
    if(a < 1 or a > (int)v.size() or b < 1 or b > (int)v[1].size())return 0;
    return v[a][b];
}

int main(){
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);

    cin >> n >> m >> D >> K;
    vector<pair<int,int>> mushroom;
    v.resize(n + 1);
    for(int i = 0; i < (int)v.size(); i++)
        v[i].resize(m + 1);

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++){
            char c; cin >> c;

            if(c == 'S')v[i][j] = 1;
            else if(c == 'M')mushroom.pb({i, j});
        }

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            v[i][j] = v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1] + v[i][j];
    
    int cnt = 0;
    for(int j = 0; j < mushroom.size(); j++){
        pair<int, int>  i = mushroom[j];
        int cor1 = v[min(n, i.F + D)][min(m, i.S + D)], cor2 = v[max(0, i.F - D - 1)][max(0, i.S - D - 1)],
            cor3 = v[min(n, i.F + D)][max(0, i.S - D - 1)], cor4 = v[max(0, i.F - D - 1)][min(m, i.S + D)];
        
        if(K <= cor1 + cor2 - cor3 - cor4)cnt++;
    }

    cout << cnt << '\n';

    return 0;
}

Compilation message

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int j = 0; j < mushroom.size(); j++){
      |                    ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 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 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 676 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1104 KB Output is correct
2 Correct 3 ms 1272 KB Output is correct
3 Correct 4 ms 1360 KB Output is correct
4 Correct 3 ms 1284 KB Output is correct
5 Correct 3 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 7372 KB Output is correct
2 Correct 13 ms 10440 KB Output is correct
3 Correct 13 ms 10440 KB Output is correct
4 Correct 11 ms 7372 KB Output is correct
5 Correct 14 ms 10440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 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 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 676 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 4 ms 1104 KB Output is correct
17 Correct 3 ms 1272 KB Output is correct
18 Correct 4 ms 1360 KB Output is correct
19 Correct 3 ms 1284 KB Output is correct
20 Correct 3 ms 1104 KB Output is correct
21 Correct 12 ms 7372 KB Output is correct
22 Correct 13 ms 10440 KB Output is correct
23 Correct 13 ms 10440 KB Output is correct
24 Correct 11 ms 7372 KB Output is correct
25 Correct 14 ms 10440 KB Output is correct
26 Correct 13 ms 4812 KB Output is correct
27 Correct 10 ms 5828 KB Output is correct
28 Correct 11 ms 3784 KB Output is correct
29 Correct 13 ms 4040 KB Output is correct
30 Correct 12 ms 6600 KB Output is correct