fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=1e9+7;
  5. const ll INF = 10000000000000;
  6. const int N = 1e6+7;
  7.  
  8. void solve() {
  9. int n;
  10. cin >> n;
  11. vector<ll> x(n), y(n);
  12. for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
  13. sort(x.begin(), x.end());
  14. sort(y.begin(), y.end());
  15. ll w = x[n-1] - x[0] + 1;
  16. ll h = y[n-1] - y[0] + 1;
  17. ll w2 = min(x[n-1] - x[1] + 1,x[n-2] - x[0] + 1);
  18. ll h2 = min(y[n-1] - y[1] + 1, y[n-2] - y[0] + 1);
  19. cout << min({w*h, w2*h, w*h2}) << "\n";
  20. }
  21.  
  22. int main(){
  23. ios::sync_with_stdio(false);
  24. cin.tie(nullptr);
  25.  
  26. int t;
  27. cin >> t;
  28. while (t--) solve();
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5316KB
stdin
7
3
1 1
1 2
2 1
5
1 1
2 6
6 4
3 3
8 2
4
1 1
1 1000000000
1000000000 1
1000000000 1000000000
1
1 1
5
1 2
4 2
4 3
3 1
3 2
3
1 1
2 5
2 2
4
4 3
3 1
4 4
1 2
stdout
2
32
1000000000000000000
1
6
4
8