Submission #1100204

# Submission time Handle Problem Language Result Execution time Memory
1100204 2024-10-13T09:44:10 Z vjudge1 Maxcomp (info1cup18_maxcomp) C++17
Compilation error
0 ms 0 KB
//UNSTOPPABLE
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
// #define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int,int>
#define tpii pair <pair <int,int> , int>
#define bruh cout << "NO\n"
using namespace std;
using namespace __gnu_pbds;
const int N = 1e3 + 5 , M = 1e6 + 5;
int mod = 1e9 + 7;
const int INF = 1e9;
int n,m,a[N][N],num[N][N],val[M],used[M];
vector <int> g[M],dist[5001][5001];
void Goldik(){
	cin >> n >> m;
	int cur = 0;
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			cin >> a[i][j];
			num[i][j] = ++cur;
			val[cur] = a[i][j];
		}
	}
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			int x = num[i][j];
			if(i != 1){
				g[x].pb(num[i - 1][j]);
			}
			if(j != 1){
				g[x].pb(num[i][j - 1]);
			}
			if(i != n){
				g[x].pb(num[i + 1][j]);
			}
			if(j != m){
				g[x].pb(num[i][j + 1]);
			}
		}
	}
	for(int i = 1 ; i <= cur ; i++){
		for(int j = 1 ; j <= cur ; j++){
			dist[i][j].pb(INF);
		}
	}
	int ans = -INF;
	for(int i = 1 ; i <= cur ; i++){
		for(int j = 1 ; j <= cur ; j++) used[j] = 0;
		deque <int> q = {};
		q.pb(i);
		dist[i][i].clear();
		dist[i][i].pb(i);
		used[i] = 1;
		while(q.size()){
			int v = q.front();
			q.ppf();
			used[v] = 1;
			for(auto to : g[v]){
				if(!used[to]){
					if(dist[i][to].back() == INF || dist[i][to].size() > dist[i][v].size() + 1){
						dist[i][to] = dist[i][v];
						dist[i][to].pb(to);
						q.pb(to);
					}
				}
			}
		}
		for(int j = 1 ; j <= cur ; j++){
			if(i == j) continue;
			// cout << "i j -- > " << i << ' ' << j << '\n';
			int mx = -INF , mn = INF;
			for(auto it : dist[i][j]){
				// cout << it << ' ';
				mx = max(mx , val[it]);
				mn = min(mn , val[it]);
			}
			// cout << '\n';
			// cout << "MX MN -- > " << mx << ' ' << mn << '\n';
			ans = max(ans , mx - mn - (ll)dist[i][j].size());
		}
	}
	cout << ans;
}
//rewai mnogo zadach vozmozhno odna iz nih gde to popadetsya
//returning winter prime?
//chem prowe tem luchshe
signed main(/*AZ AZDAN UZDIKSIZ*/){
	//freopen("txt.in","r",stdin);
	//freopen("txt.out","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	srand(time(0));
	int TT = 1;
	// cin >> TT;
	for(int i = 1 ; i <= TT ; i++){
		//cout << "Case " << i << ": ";
		Goldik();
	}
}

Compilation message

maxcomp.cpp: In function 'void Goldik()':
maxcomp.cpp:88:51: error: no matching function for call to 'max(int&, long long int)'
   88 |    ans = max(ans , mx - mn - (ll)dist[i][j].size());
      |                                                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from maxcomp.cpp:2:
/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:
maxcomp.cpp:88:51: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   88 |    ans = max(ans , mx - mn - (ll)dist[i][j].size());
      |                                                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from maxcomp.cpp:2:
/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:
maxcomp.cpp:88:51: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   88 |    ans = max(ans , mx - mn - (ll)dist[i][j].size());
      |                                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from maxcomp.cpp:2:
/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:
maxcomp.cpp:88:51: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   88 |    ans = max(ans , mx - mn - (ll)dist[i][j].size());
      |                                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from maxcomp.cpp:2:
/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:
maxcomp.cpp:88:51: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   88 |    ans = max(ans , mx - mn - (ll)dist[i][j].size());
      |                                                   ^