이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 (abs(pos.real())+1) * (abs(pos.imag())+1);
}
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 minX = 1e18;
int minY = 1e18;
for(auto e: merges){
if(e.real() == 0){
minX = min(minX, abs(e.imag()));
}
else{
if(e.imag()!=0){
minX = min(minX, 2*abs(e.imag()));
}
}
if(e.imag() ==0){
minY = min(minY, abs(e.real()));
}
else{
if(e.real()!=0){
minY = min(minY, 2*abs(e.real()));
}
}
}
int res= 1e18;
for(auto e: merges){
if(e.real()!=0){
res= min(res, minX*abs(e.real()));
}
}
cout<<res<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:45:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::complex<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int i = 1; i<merges.size(); i++){
| ~^~~~~~~~~~~~~~
# | 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... |