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;
#define pb push_back
int N, horiz, vert, x[100005], y[100005];
map<int, vector<int> > row, col;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> x[i] >> y[i];
row[x[i]].pb(y[i]);
col[y[i]].pb(x[i]);
}
for (auto i : row) {
sort(i.second.begin(), i.second.end());
if (i.second.size() > 1) {
for (int j = 0; j + 1 < (int)i.second.size(); j++) {
horiz = __gcd(horiz, i.second[j + 1] - i.second[j]);
}
}
}
for (auto i : col) {
sort(i.second.begin(), i.second.end());
if (i.second.size() > 1) {
for (int j = 0; j + 1 < (int)i.second.size(); j++) {
vert = __gcd(vert, i.second[j + 1] - i.second[j]);
}
}
}
if (horiz == 0 || vert == 0) {
cout << "-1\n";
} else {
cout << (long long)horiz * vert << '\n';
}
}
# | 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... |