이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
const int N=1e5+5;
int x[N],y[N],n;
map<int,vector<int>> mpx,mpy;
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n;
for (int i=1;i<=n;i++) cin>>x[i]>>y[i];
if (n<=2){
cout<<-1<<endl;
return 0;
}
sort(x+1,x+1+n);
sort(y+1,y+1+n);
//for (int i=1;i<=n;i++) cout<<x[i]<<' '<<
if (x[1]==x[n] || y[1]==y[n]){
cout<<-1<<endl;
return 0;
}
int x1=x[1],x2,y1=y[1],y2;
for (int i=2;i<=n;i++){
if (x[i]==x1) continue;
x2=x[i];
break;
}
for (int i=2;i<=n;i++){
if (y[i]==y1) continue;
y2=y[i];
break;
}
cout<<(x2-x1)*(y2-y1)<<endl;
/*if (x[1]==x[2] && x[1]==x[3]){
cout<<-1<<endl;
return 0;
}
if (y[1]==y[2] && y[1]==y[3]){
cout<<-1<<endl;
return 0;
}
if (x[1]!=x[2] && x[1]!=x[3] && x[2]!=x[3] && y[1]!=y[2] && y[1]!=y[3] && y[2]!=y[3]){
cout<<-1<<endl;
return 0;
}
sort(x+1,x+1+n);
sort(y+1,y+1+n);
int X=x[3]-x[1]+1,Y=y[3]-y[1]+1;
cout<<X*Y-X-Y+1<<endl;*/
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int32_t main()':
Main.cpp:45:14: warning: 'x2' may be used uninitialized in this function [-Wmaybe-uninitialized]
45 | cout<<(x2-x1)*(y2-y1)<<endl;
| ~~~^~~~
Main.cpp:45:22: warning: 'y2' may be used uninitialized in this function [-Wmaybe-uninitialized]
45 | cout<<(x2-x1)*(y2-y1)<<endl;
| ~~~^~~~
# | 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... |