Pagini recente » Cod sursa (job #1007475) | Cod sursa (job #347209) | Cod sursa (job #2529091) | Cod sursa (job #163303) | Cod sursa (job #2204918)
#include <bits/stdc++.h>
#define MAXN 800
struct Point{ long long x, y;} v[1 + 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 = 1; i <= n; i++)
fscanf(fi,"%lld%lld", &v[i].x, &v[i].y);
for(int i = 1; i <= n; i++)
for(int j = i + 1; j <= n; j++){
Point A = v[i], B = v[i % n + 1];
Point C = v[j], D = v[j % n + 1];
if(A.y == B.y || C.y == D.y)
continue;
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;
}