Submission #970428

# Submission time Handle Problem Language Result Execution time Memory
970428 2024-04-26T14:02:53 Z NoMercy Collecting Mushrooms (NOI18_collectmushrooms) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
    

#define file \
            freopen("in.txt" , "r" , stdin); \
            freopen("out.txt" , "w" , stdout);
 
#define int long long

void test_case () {
    int n , m , d , k;
    cin >> n >> m >> d >> k;
    string c[n];
    vector<vector<int>> pre(n + 2 , vector<int> (m + 2 , 0));
    for (int i = 0;i < n;i ++) {
        cin >> c[i];
    }
    for (int i = 1;i <= n;i ++) {
        for (int j = 1;j <= m;j ++) {
            assert(c[i - 1][j - 1] == 'S' || c[i - 1][j - 1] == 'M' || c[i - 1][j - 1] == '.');
            if (c[i - 1][j - 1] == 'S') {
                pre[max(0 , i - d)][max(0 , j - d)] ++;
                pre[min(n + 1 , i + d + 1)][min(m + 1 , j + d + 1)] ++;
                pre[min(n + 1 , i + d + 1)][max(0 , j - d)] --;
                pre[max(0 , i - d)][min(m + 1 , j + d + 1)] --;
            }
        }
    }
    for (int i = 0;i <= n;i ++) {
        for (int j = 0;j <= m;j ++) {
            if (i > 0) {
                pre[i][j] += pre[i - 1][j];
            }
            if (j > 0) {
                pre[i][j] += pre[i][j - 1];
            }
            if (i > 0 && j > 0) {
                pre[i][j] -= pre[i - 1][j - 1];
            }
        }
    }
    // for (int i = 1;i <= n;i ++) {
    //     for (int j = 1;j <= m;j ++) {
    //         cout << pre[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    int res = 0;
    for (int i = 1;i <= m;i ++) {
        for (int j = 1;j <= m;j ++) {
            res += bool(c[i - 1][j - 1] == 'M' && pre[i][j] >= k);
        }
    }
    cout << res << endl;
}

/*


.......
.......
.......
.......
.......

*/
 
int32_t main () {
 
    /////    file
    
 
    int t = 1;
    // cin >> t;
 
    while (t --) {
        test_case();
    }

    return 0;
}

Compilation message

mushrooms.cpp: In function 'void test_case()':
mushrooms.cpp:24:34: error: no matching function for call to 'max(int, long long int)'
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:24:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:24:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:24:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:24:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                  ^
mushrooms.cpp:24:50: error: no matching function for call to 'max(int, long long int)'
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:24:50: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:24:50: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:24:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:24:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |                 pre[max(0 , i - d)][max(0 , j - d)] ++;
      |                                                  ^
mushrooms.cpp:26:58: error: no matching function for call to 'max(int, long long int)'
   26 |                 pre[min(n + 1 , i + d + 1)][max(0 , j - d)] --;
      |                                                          ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:26:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   26 |                 pre[min(n + 1 , i + d + 1)][max(0 , j - d)] --;
      |                                                          ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:26:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   26 |                 pre[min(n + 1 , i + d + 1)][max(0 , j - d)] --;
      |                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:26:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |                 pre[min(n + 1 , i + d + 1)][max(0 , j - d)] --;
      |                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:26:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |                 pre[min(n + 1 , i + d + 1)][max(0 , j - d)] --;
      |                                                          ^
mushrooms.cpp:27:34: error: no matching function for call to 'max(int, long long int)'
   27 |                 pre[max(0 , i - d)][min(m + 1 , j + d + 1)] --;
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:27:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   27 |                 pre[max(0 , i - d)][min(m + 1 , j + d + 1)] --;
      |                                  ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:27:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   27 |                 pre[max(0 , i - d)][min(m + 1 , j + d + 1)] --;
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:27:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |                 pre[max(0 , i - d)][min(m + 1 , j + d + 1)] --;
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:27:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |                 pre[max(0 , i - d)][min(m + 1 , j + d + 1)] --;
      |                                  ^