Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

typedef pair<int,int> P;

const int N=2e5+5;
const int INF=numeric_limits<int>::max();
int n,x[N],y[N],mn[N],mx[N];
set<P> Smin,Smax;
P Rx,Rn,Bx,Bn;

void del(int id){
	Smin.erase({mn[id],id});
	Smax.erase({mx[id],id});
}

void add(int id){
	Smin.emplace(mn[id],id);
	Smax.emplace(mx[id],id);
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>x[i]>>y[i];
		mn[i]=min(x[i],y[i]);
		mx[i]=max(x[i],y[i]);
		Smin.emplace(mn[i],i);
		Smax.emplace(mx[i],i);
	}
	ll res=numeric_limits<ll>::max();
	//choose Rmin->Rmax->Bmin->Bmax
	Rn=*Smin.begin();
	auto it=Smax.rbegin();
	if(it->second==Rn.second) it--;
	Rx=*it;
	if(mx[Rn.second]<mn[Rx.second]) 
		Bn={mx[Rn.second],Rn.second},		
		Bx={mn[Rx.second],Rx.second};
	else
		Bn={mn[Rx.second],Rx.second},
		Bx={mx[Rn.second],Rn.second};
	//choose Bmin first
	P oldBn=Bn,oldBx=Bx;
	if(Smax.begin()->first<Bn.first) Bn=*Smax.begin();
	for(int i=0;i<n;++i)
		if(i!=Rn.second&&i!=Rx.second&&i!=Bn.second){
			if(mn[i]<Bn.first) Bx.first=max(Bx.first,mx[i]);
			else Bx.first=max(Bx.first,mn[i]);
		}
	res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
	//choose Bmax first
	Bn=oldBn,Bx=oldBx;
	if(Smin.rbegin()->first>Bx.first) Bx=*Smin.rbegin();
	for(int i=0;i<n;++i)
		if(i!=Rn.second&&i!=Rx.second&&i!=Bx.second){
			if(mx[i]>Bx.first) Bn.first=min(Bn.first,mn[i]);
			else Bn.first=min(Bn.first,mx[i]);
		}
	res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
	//choose Bmin->Rmax->Bmax->Rmin
	Bn=Rn;
	Rn={mx[Bn.second],Bn.second};
	Bx={mn[Rx.second],Rx.second};
	P oldRn=Rn;
	oldBx=Bx;
	//choose Rmin first
	if(Smax.begin()->first<Rn.first) Rn=*Smax.begin();
	for(int i=0;i<n;++i)
		if(i!=Rn.second&&i!=Rx.second&&i!=Bn.second){
			if(mx[i]>=Rn.first) Bx.first=max(Bx.first,mn[i]);
			else Bx.first=max(Bx.first,mx[i]);
		}
	res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
	//choose Bmax first
	Rn=oldRn;
	Bx=oldBx;
	if(Smin.rbegin()->first>Bx.first) Bx=*Smin.rbegin();
	for(int i=0;i<n;++i)
		if(i!=Rx.second&&i!=Bn.second&&i!=Bx.second){
			if(mn[i]<=Bx.first) Rn.first=min(Rn.first,mx[i]);
			else Rn.first=min(Rn.first,mn[i]);
		}
	res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
//	cerr<<Rx.first<<' '<<Rn.first<<' '<<Bx.first<<' '<<Bn.first<<'\n';
	cout<<res<<'\n';
}




Compiler output:
a.cc: In function 'int main()':
a.cc:53:16: error: no matching function for call to 'min(int64_t&, long long int)'
   53 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:53:16: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   53 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:53:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   53 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:62:16: error: no matching function for call to 'min(int64_t&, long long int)'
   62 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:62:16: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   62 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:62:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   62 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:76:16: error: no matching function for call to 'min(int64_t&, long long int)'
   76 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:76:16: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   76 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:76:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   76 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:86:16: error: no matching function for call to 'min(int64_t&, long long int)'
   86 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:86:16: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   86 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:86:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   86 |         res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~