# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1063252 | anton | Portal (BOI24_portal) | C++17 | 910 ms | 1048576 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;
#define int long long
#define pii pair<int, int>
#define p complex<int>
const int MAX_N = 3e5+1;
int N;
int mod(p pos){
return pos.real() * pos.real() + pos.imag()* pos.imag();
}
int cross_prod(p a, p b){
return (conj(a) * b).imag();
}
signed main(){
cin>>N;
vector<p> portals;
for(int i = 0; i<N; i++){
int a, b;
cin>>a>>b;
portals.push_back({a, b});
}
if(N == 2){
cout<<-1<<endl;
return 0;
}
vector<p> merges;
for(int i = 0; i<N; i++){
for(int j = 0; j<N; j++){
if(i != j){
merges.push_back(portals[i]-portals[j]);
}
}
}
bool ok = false;
for(int i = 1; i<merges.size(); i++){
if(cross_prod(merges[i-1], merges[i]) != 0){
ok = true;
}
}
if(merges.size() == 0 || !ok){
cout<<-1<<endl;
return 0;
}
int res = 1e18;
for(auto e: merges){
res = min(res, mod(e));
}
cout<<res<<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... |