#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Point pair<int,int>
#define x first
#define y second
struct Line {
Point p,q;
Line(int a=0, int b=0, int c=0, int d=0){
p=Point(a,b);
q=Point(c,d);
}
};
int cross(Point A, Point B, Point C){
int xAB=B.x-A.x, yAB=B.y-A.y;
int xAC=C.x-A.x, yAC=C.y-A.y;
int res=xAB*yAC-xAC*yAB;
if(res<0) return -1;
if(res==0) return 0;
return 1;
}
int isIntersect(Line A, Line B) {
return cross(A.p,A.q,B.p) != cross(A.p,A.q,B.q) && cross(B.p,B.q,A.p) != cross(B.p,B.q,A.q);
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin>>n;
Point a[n];
for(int i=0;i<n;++i) cin>>a[i].x>>a[i].y;
vector<pair<pair<int,int>,Line>> lines;
for(int i=0;i<n;++i) for(int j=i+1;j<n;++j){
lines.push_back({{i,j},Line(a[i].x,a[i].y,a[j].x,a[j].y)});
}
int ans=0;
int sz=lines.size();
for(int i=0;i<sz;++i) {
bool f=0;
for(int j=0;j<sz&&!f;++j) if(i!=j
&&lines[i].first.first!=lines[j].first.first
&&lines[i].first.second!=lines[j].first.first
&&lines[i].first.first!=lines[j].first.second
&&lines[i].first.second!=lines[j].first.second) {
f|=isIntersect(lines[i].second,lines[j].second);
}
ans+=(!f);
}
cout<<ans<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |