This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<ll,ll>;
#define REP(i,n) for (int i = 0; i < n; i++)
#define trav(a,x) for (auto& a : x)
#define D(x) cerr << #x << ": " << x << endl;
#define all(x) (x).begin(), (x).end()
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
if (n == 2) {
cout << "-1" << endl;
return 0;
}
vector<pi> p(n);
vector<pi> p2(n);
REP(i,n) {
cin >> p[i].first >> p[i].second;
p2[i].second = p[i].first;
p2[i].first = p[i].second;
}
sort(all(p));
sort(all(p2));
if (p.begin()->first == p.rbegin()->first || p2.begin()->first == p2.rbegin()->first) {
cout << "-1" << endl;
return 0;
}
ll mx = 1e10;
ll my = 1e10;
REP(i,n) {
if (i==0) continue;
if (p[i-1].first!=p[i].first) mx = min(mx, p[i].first-p[i-1].first);
if (p2[i-1].first!=p2[i].first) my = min(my, p2[i].first-p2[i-1].first);
}
cout << 1+(mx-1)*(my-1)+(mx-1)+(my-1) << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |