double x = .0, y = .0; } mat[MAXN], pro[MAXN]; // material and product
int n, m, ans(0x3f3f3f3f), dis[MAXN][MAXN];
inlinevoidinit(){ memset(dis, 0x3f, sizeof(dis)); for (int i = 1; i <= m; i++) for (int j = 1; j <= m; j++) { bool connect = true; for (int k = 1; k <= n; k++) {//判断是否能作为凸包的边 double cross = (mat[j] - mat[i]) * (pro[k] - mat[i]); double dot = dotProduct(mat[j] - pro[k], mat[i] - pro[k]); if (cross < -EPSILON || (abs(cross) < EPSILON && dot > EPSILON)) connect = false; } if (connect) dis[i][j] = 1; } }
inlinevoidfloyed(){ //floyed求最小环 for (int k = 1; k <= m; k++) for (int i = 1; i <= m; i++) for (int j = 1; j <= m; j++) { dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); } for (int i = 1; i <= m; i++) ans = min(ans, dis[i][i]); cout << (ans == 0x3f3f3f3f ? -1 : ans) << endl; }
intmain(){ std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> m >> n;
double a, b, c; for (int i = 1; i <= m; i++) { cin >> a >> b >> c; mat[i] = Vector(a, b); } for (int i = 1; i <= n; i++) { cin >> a >> b >> c; pro[i] = Vector(a, b); } init(); floyed(); return0; }