# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1051446 | deera | 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>
using namespace std;
struct Portal {
public:
int x;
int y;
};
void print(Portal p) {
cout << p.x << " " << p.y << endl;
}
void solve() {
int n;
cin >> n;
vector<Portal> portals(n);
for (int i = 0; i < n; i++)
cin >> portals[i].x >> portals[i].y;
if (n <= 2) return (void)(cout << -1 << endl);
int box_x = 0;
int box_y = 0;
Portal c = portals[0];
for(auto p: portals) {
box_x = __gcd(abs(p.x - c.x), box_x);
box_y = __gcd(abs(p.y - c.x), box_y);
}
int n = box_x * box_y;
if (n == 0) cout << -1 << endl;
else cout << n << endl;
}
int main() {solve();}