Submission #337950

#TimeUsernameProblemLanguageResultExecution timeMemory
337950kutbilim_oneUFO (IZhO14_ufo)C++14
Compilation error
0 ms0 KiB
/** kutbilim.one **/ #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end() //#define int long long #define endl '\n' /* ifstream in("test.txt"); #define cin in */ int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m, r, k, p; cin >> n >> m >> r >> k >> p; int a[1+n][1+m]; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> a[i][j]; vector<int> maxi(n+1, -1), maxj(m+1, -1); while(k--){ char side; int pos, h; cin >> side >> pos >> h; int shots = r; if(side == 'W' && (maxi[pos] == -1 || maxi[pos] >= h)){ for(int j = 1; j <= m && shots > 0; j++){ if(a[pos][j] >= h) a[pos][j]--, shots--; if(maxi[pos] == -1 || maxi[pos] < a[pos][j]) maxi[pos] = a[pos][j]; } }else if(side == 'E' && (maxi[pos] == -1 || maxi[pos] >= h)){ for(int j = m; j >= 1 && shots > 0; j--){ if(a[pos][j] >= h) a[pos][j]--, shots--; if(maxi[pos] == -1 || maxi[pos] < a[pos][j]) maxi[pos] = a[pos][j]; } }else if(side == 'N' && (maxj[pos] == -1 || maxj[pos] >= h)){ for(int i = 1; i <= n && shots > 0; i++){ if(a[i][pos] >= h) a[i][pos]--, shots--; if(maxj[pos] == -1 || maxj[pos] < a[i][pos]) maxj[pos] = a[i][pos]; } }else if(side == 'S' && (maxj[pos] == -1 || maxj[pos] >= h)){ for(int i = n; i >= 1 && shots > 0; i--){ if(a[i][pos] >= h) a[i][pos]--, shots--; if(maxj[pos] == -1 || maxj[pos] < a[i][pos]) maxj[pos] = a[i][pos]; } } } long long sums[1+n][1+m] = {{}}; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ sums[i][j] += a[i][j] + sums[i][j-1]; } } int maxx = 0; for(int j = 1; j <= m; j++){ for(int i = 1; i <= n; i++){ sums[i][j] += sums[i-1][j]; if(i >= p && j >= p) maxx = max(maxx, sums[i][j]-sums[i][j-p]-sums[i-p][j]+sums[i-p][j-p]); } } cout << maxx; return 0; }

Compilation message (stderr)

ufo.cpp: In function 'int main()':
ufo.cpp:65:99: error: no matching function for call to 'max(int&, long long int)'
   65 |          if(i >= p && j >= p) maxx = max(maxx, sums[i][j]-sums[i][j-p]-sums[i-p][j]+sums[i-p][j-p]);
      |                                                                                                   ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from ufo.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
ufo.cpp:65:99: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   65 |          if(i >= p && j >= p) maxx = max(maxx, sums[i][j]-sums[i][j-p]-sums[i-p][j]+sums[i-p][j-p]);
      |                                                                                                   ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from ufo.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
ufo.cpp:65:99: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   65 |          if(i >= p && j >= p) maxx = max(maxx, sums[i][j]-sums[i][j-p]-sums[i-p][j]+sums[i-p][j-p]);
      |                                                                                                   ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ufo.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
ufo.cpp:65:99: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   65 |          if(i >= p && j >= p) maxx = max(maxx, sums[i][j]-sums[i][j-p]-sums[i-p][j]+sums[i-p][j-p]);
      |                                                                                                   ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ufo.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
ufo.cpp:65:99: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   65 |          if(i >= p && j >= p) maxx = max(maxx, sums[i][j]-sums[i][j-p]-sums[i-p][j]+sums[i-p][j-p]);
      |                                                                                                   ^