Submission #1126340

#TimeUsernameProblemLanguageResultExecution timeMemory
1126340I_love_BanuMaxcomp (info1cup18_maxcomp)C++20
Compilation error
0 ms0 KiB
#include"bits/stdc++.h" using namespace std; using ll=long long; using ld=long double; using str=string; template<class T,class U>using P=pair<T,U>; using pi=P<int,int>; template<class T>using V=vector<T>; using vi=V<int>; using vl=V<ll>; using vvi=V<vi>; using vpi=V<pair<int,int>>; template<class T>int lwb(V<T>&a,T b){return int(lb(all(a),b)-begin(a));} template<class T>int lwb(T a[],int n,T b){return int(lb(a,a+n,b)-a);} template<class T>int upb(V<T>&a,T b){return int(ub(all(a),b)-begin(a));} template<class T>int upb(T a[],int n,T b){return int(ub(a,a+n,b)-a);} template<class T>ll sum(V<T>&a){return accumulate(all(a),0ll);} template<class T>ll sum(T a[],int n){return accumulate(a,a+n,0ll);} template<class T>T MAX(V<T>&a){return *max_element(all(a));} template<class T>T MAX(T a[],int n){return *max_element(a,a+n);} template<class T>T MIN(V<T>&a){return *min_element(all(a));} template<class T>T MIN(T a[],int n){return *min_element(a,a+n);} template<class T,class U>ifstream&operator>>(istream&in,P<T,U>a){return in>>a.first>>a.second;} #define sz(x)int(size(x)) #define all(x)begin(x),end(x) #define lla(x)rbegin(x),rend(x) #define lb lower_bound #define ub upper_bound #define FOR(i,a,b)for(int i=(a);i<(b);i++) #define F0R(i,a)FOR(i,0,a) #define ROF(i,a,b)for(int i=(b)-1;(a)<=i;i--) #define R0F(i,a)ROF(i,0,a) #define rep(a)F0R(_,a) #define each(a,x)for(auto&a:x) #define con const int con mxN = 1e3 + 3; ll A[mxN][mxN][2]; ll B[mxN][mxN][2]; ll a[mxN][mxN]; main(){ int N, M; cin >> N >> M; F0R(i, N){ F0R(j, M){ cin >> a[i][j]; } } fill(A, A + mxN * mxN * 2, LLONG_MAX); fill(A, A + mxN * mxN * 2, LLONG_MIN); ll ans = LLONG_MIN; F0R(i, N){ F0R(j, M){ A[i][j][0] = a[i][j] + 1; B[i][j][0] = a[i][j] - 1; if (0 < i){ A[i][j][0] = min(A[i][j][0], A[i - 1][j][0] + 1); B[i][j][0] = max(B[i][j][0], B[i - 1][j][0] - 1); } if (0 < j){ A[i][j][0] = min(A[i][j][0], A[i][j - 1][0] + 1); B[i][j][0] = max(B[i][j][0], B[i][j - 1][0] - 1); } } R0F(j, M){ A[i][j][1] = a[i][j] + 1; B[i][j][1] = a[i][j] - 1; if (0 < i){ A[i][j][1] = min(A[i][j][1], A[i - 1][j][0] + 1); B[i][j][1] = max(B[i][j][1], B[i - 1][j][0] - 1); } if (j < M - 1){ A[i][j][1] = min(A[i][j][1], A[i][j + 1][0] + 1); B[i][j][1] = max(B[i][j][1], B[i][j + 1][0] - 1); } } F0R(j, M){ ll mn = LLONG_MAX; if (0 < i){ mn = min({mn, A[i - 1][j][0], A[i - 1][j][1]}); } if (0 < j){ mn = min(mn, A[i][j - 1][0]); } if (j < M - 1){ mn = min(mn, A[i][j + 1][1]); } mn ++; ans = max(ans, a[i][j] - mn); ll mx = LLONG_MIN; if (0 < i){ mx = max({mx, B[i - 1][j][0], B[i - 1][j][1]}); } if (0 < j){ mx = max(mx, B[i][j - 1][0]); } if (j < M - 1){ mx = max(mx, B[i][j + 1][1]); } mx --; ans = max(ans, mx - a[i][j]); } } cout << ans << endl; }

Compilation message (stderr)

maxcomp.cpp:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main(){
      | ^~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from maxcomp.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h: In instantiation of 'constexpr typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = long long int (*)[1003][2]; _Tp = long long int; typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/11/bits/stl_algobase.h:969:21:   required from 'constexpr void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = long long int (*)[1003][2]; _Tp = long long int]'
/usr/include/c++/11/bits/stl_algobase.h:999:20:   required from 'constexpr void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = long long int (*)[1003][2]; _Tp = long long int]'
maxcomp.cpp:53:9:   required from here
/usr/include/c++/11/bits/stl_algobase.h:924:18: error: incompatible types in assignment of 'const long long int' to 'long long int [1003][2]'
  924 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~