# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
994640 | PenguinsAreCute | Portal (BOI24_portal) | C++17 | 2089 ms | 1116 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.
// yay linear algebra!
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
main() {
int n; cin >> n;
int x[n], y[n]; for(int i=0;i<n;i++) cin>>x[i]>>y[i];
for(int i=1;i<n;i++) x[i]-=x[0],y[i]-=y[0];
int g = 0; for(int i=1;i<n;i++) g=__gcd(g,x[i]);
g=abs(g);
if(!g) {cout<<"-1"; return 0;}
for(int i=1;i<n;i++) x[i]/=g;
ll g2 = 0;
for(int i=1;i<n;i++) for(int j=i+1;j<n;j++) g2=__gcd(g2,1LL*x[i]*y[j]-1LL*x[j]*y[i]);
if(!g2) {cout<<"-1"; return 0;}
cout << abs(g * g2) << "\n";
}
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... |