Pagini recente » Cod sursa (job #2935164) | Cod sursa (job #3274854) | Cod sursa (job #2963272) | Cod sursa (job #2860275) | Cod sursa (job #2204919)
#include <bits/stdc++.h>
#define MAXN 800
struct Point{ long long x, y;} v[MAXN];
inline long long S(Point A, Point B, Point C){
return 1LL * A.x * B.y + 1LL * B.x * C.y + 1LL * C.x * A.y - 1LL * A.y * B.x - 1LL * B.y * C.x - 1LL * C.y * A.x;
}
inline int sgn(long long a){
if(a == 0) return 0;
if(a > 0) return 1;
return -1;
}
int main(){
FILE*fi,*fo;
fi = fopen("poligon.in","r");
fo = fopen("poligon.out","w");
int n, m;
fscanf(fi,"%d%d", &n, &m);
for(int i = 0; i < n; i++)
fscanf(fi,"%lld%lld", &v[i].x, &v[i].y);
for(int i = 0; i < n - 1; i++)
for(int j = i + 1; j < n; j++){
Point A = v[i], B = v[(i + 1) % n];
Point C = v[j], D = v[(j + 1) % n];
if(sgn(S(A, B, C)) * sgn(S(B, C, D)) * sgn(S(C, D, A)) * sgn(S(D, A, B)) && sgn(S(C, D, A)) + sgn(S(C, D, B)) == 0 && sgn(S(A, B, C)) + sgn(S(A, B, D)) == 0)
assert(0);
}
return 0;
}