Pagini recente » Cod sursa (job #2386088) | Cod sursa (job #2843426) | Cod sursa (job #15953) | Cod sursa (job #2681577) | Cod sursa (job #2226761)
#include <bits/stdc++.h>
#define MAXN 800
struct Point{ int x, y;} v[1 + MAXN];
inline long long S(Point A, Point B, Point C){
return (long long)(1LL * A.x * B.y + 1LL * A.y * C.x + 1LL * B.x * C.y) -
(long long)(1LL * A.x * C.y + 1LL * A.y * B.x + 1LL * C.x * B.y);
}
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,"%d%d", &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(A, B, D)) &&
sgn(S(A, B, C)) * sgn(S(A, B, D)) &&
sgn(S(C, D, A)) != sgn(S(C, D, B)) &&
sgn(S(C, D, A)) * sgn(S(C, D, B))) assert(0);
}
return 0;
}