# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1054612 | anango | Portal (BOI24_portal) | C++17 | 43 ms | 6432 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 int long long
using namespace std;
signed main() {
int local = 0;
if (local) {
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
}
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#endif //fast IO
int n; cin >> n;
vector<pair<int,int>> cords;
vector<int> xv;
vector<int> yv;
for (int i=0; i<n; i++) {
int x,y; cin >> x >> y;
cords.push_back({x,y});
xv.push_back(x);
yv.push_back(y);
}
sort(xv.begin(), xv.end()); sort(yv.begin(), yv.end());
int gx,gy;
gx=gy=0;
for (int i=0; i<n-1; i++) {
gx=gcd(gx,xv[i+1]-xv[i]);
gy=gcd(gy,yv[i+1]-yv[i]);
}
if (gx==0 || gy==0) {
cout << -1 << endl;
return 0;
}
cout << gx*gy << endl;
}
Compilation message (stderr)
# | 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... |