Submission #464501

#TimeUsernameProblemLanguageResultExecution timeMemory
464501kilikumaT-Covering (eJOI19_covering)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long maxi=0; int m, n; bool dans(int lig, int col) { if (lig<0||col<0||lig>=m||col>=n) return false; else return true; } int main() { int m, n; scanf("%d%d", &m,&n); int grille[1000000][10000000]; for (int lig=0;lig<m;lig++) { for (int col=0;col<n;col++) { cin >> grille[lig][col]; } } int k; cin >> k ; for (int i=0;i<k;i++) { int r, c; cin >> r >> c; long maxiCur = 0; // premier cas if (dans(r-1,c-1)&&dans(r-1,c+1)&&dans(r-1,c)) { maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r-1][c]+grille[r-1][c+1]+grille[r][c]); } if (dans(r-1,c+1)&&dans(r+1,c+1)&&dans(r,c+1)) { maxiCur= max(maxiCur, grille[r-1][c+1]+grille[r][c+1]+grille[r+1][c+1]+grille[r][c]); } if (dans(r+1,c-1)&&dans(r+1,c+1)&&dans(r+1,c)) { maxiCur = max(maxiCur, grille[r+1][c-1]+grille[r+1][c]+grille[r+1][c+1]+grille[r][c]); } if (dans(r-1,c-1)&&dans(r+1,c-1)&&dans(r,c-1)) { maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r][c-1]+grille[r+1][c-1]+grille[r][c]); } // 2 // 3 // 4 maxi += maxiCur; } printf("%ld\n", maxi); }

Compilation message (stderr)

covering.cpp: In function 'int main()':
covering.cpp:24:91: error: no matching function for call to 'max(long int&, int)'
   24 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r-1][c]+grille[r-1][c+1]+grille[r][c]);
      |                                                                                           ^
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 covering.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:
covering.cpp:24:91: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   24 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r-1][c]+grille[r-1][c+1]+grille[r][c]);
      |                                                                                           ^
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 covering.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:
covering.cpp:24:91: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   24 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r-1][c]+grille[r-1][c+1]+grille[r][c]);
      |                                                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from covering.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:
covering.cpp:24:91: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   24 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r-1][c]+grille[r-1][c+1]+grille[r][c]);
      |                                                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from covering.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:
covering.cpp:24:91: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   24 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r-1][c]+grille[r-1][c+1]+grille[r][c]);
      |                                                                                           ^
covering.cpp:27:90: error: no matching function for call to 'max(long int&, int)'
   27 |       maxiCur= max(maxiCur, grille[r-1][c+1]+grille[r][c+1]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                          ^
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 covering.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:
covering.cpp:27:90: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   27 |       maxiCur= max(maxiCur, grille[r-1][c+1]+grille[r][c+1]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                          ^
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 covering.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:
covering.cpp:27:90: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   27 |       maxiCur= max(maxiCur, grille[r-1][c+1]+grille[r][c+1]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from covering.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:
covering.cpp:27:90: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   27 |       maxiCur= max(maxiCur, grille[r-1][c+1]+grille[r][c+1]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from covering.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:
covering.cpp:27:90: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   27 |       maxiCur= max(maxiCur, grille[r-1][c+1]+grille[r][c+1]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                          ^
covering.cpp:30:91: error: no matching function for call to 'max(long int&, int)'
   30 |       maxiCur = max(maxiCur, grille[r+1][c-1]+grille[r+1][c]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                           ^
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 covering.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:
covering.cpp:30:91: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   30 |       maxiCur = max(maxiCur, grille[r+1][c-1]+grille[r+1][c]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                           ^
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 covering.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:
covering.cpp:30:91: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   30 |       maxiCur = max(maxiCur, grille[r+1][c-1]+grille[r+1][c]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from covering.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:
covering.cpp:30:91: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   30 |       maxiCur = max(maxiCur, grille[r+1][c-1]+grille[r+1][c]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from covering.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:
covering.cpp:30:91: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   30 |       maxiCur = max(maxiCur, grille[r+1][c-1]+grille[r+1][c]+grille[r+1][c+1]+grille[r][c]);
      |                                                                                           ^
covering.cpp:33:91: error: no matching function for call to 'max(long int&, int)'
   33 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r][c-1]+grille[r+1][c-1]+grille[r][c]);
      |                                                                                           ^
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 covering.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:
covering.cpp:33:91: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   33 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r][c-1]+grille[r+1][c-1]+grille[r][c]);
      |                                                                                           ^
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 covering.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:
covering.cpp:33:91: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   33 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r][c-1]+grille[r+1][c-1]+grille[r][c]);
      |                                                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from covering.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:
covering.cpp:33:91: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   33 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r][c-1]+grille[r+1][c-1]+grille[r][c]);
      |                                                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from covering.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:
covering.cpp:33:91: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   33 |       maxiCur = max(maxiCur, grille[r-1][c-1]+grille[r][c-1]+grille[r+1][c-1]+grille[r][c]);
      |                                                                                           ^
covering.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d%d", &m,&n);
      |   ~~~~~^~~~~~~~~~~~~~~