# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1095106 | SalihSahin | Portal (BOI24_portal) | C++14 | 0 ms | 0 KiB |
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>
#define pb push_back
#define int long long
using namespace std;
const int N = 3e5 + 5;
const int K = 20;
const int mod = 1e9 + 7;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n;
cin>>n;
vector<array<int, 2> > p(n);
vector<int> x(n), y(n);
for(int i = 0; i < n; i++){
cin>>p[i][0]>>p[i][1];
x[i] = p[i][0];
y[i] = p[i][1];
}
if(n <= 2){
cout<<-1<<endl;
return 0;
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
int df1 = 0, df2 = 0;
for(int i = 0; i < n-1; i++){
df1 = gcd(df1, x[i+1] - x[i]);
df2 = gcd(df2, y[i+1] - y[i]);
}
cout<<df1 * df2<<endl;
return 0;
}