이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Portal {
public:
ll x;
ll y;
};
void print(Portal p) {
cout << p.x << " " << p.y << endl;
}
ll gcd(ll x, ll y) {
return (ll)__gcd((int)x, (int)y);
}
void solve() {
ll n;
cin >> n;
vector<Portal> portals(n);
for (ll i = 0; i < n; i++)
cin >> portals[i].x >> portals[i].y;
if (n <= 2) return (void)(cout << -1 << endl);
ll box_x = 0;
ll box_y = 0;
Portal c = portals[0];
for(auto p: portals) {
box_x = gcd(std::abs(p.x - c.x), box_x);
box_y = gcd(std::abs(p.y - c.y), box_y);
}
ll a = box_x * box_y;
if (a == 0) cout << -1 << endl;
else cout << a << endl;
}
int main() {solve();}
# | 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... |