大佬救救80分的孩子吧

P3958 [NOIP2017 提高组] 奶酪

```cpp #include <iostream> #include <cmath> #include <cstring> using namespace std; int t, n, h, r, xyz[1005][3], down[1005], cnt, up[1005], arr[1005][1005], mark[1005]; int func(int now) { if (up[now] == 1) { return 1; } for (int i = 1; i <= n; i++) { if (arr[now][i] == 1 && mark[i] == 0) { mark[i] = 1; if (func(i) == 1) { return 1; } } } return 0; } int main() { cin >> t; while (t--) { cnt = 0; memset(up, 0, sizeof(up)); memset(arr, 0 ,sizeof(arr)); memset(mark, 0, sizeof(mark)); cin >> n >> h >> r; for (int i = 1; i <= n; i++) { cin >> xyz[i][0] >> xyz[i][1] >> xyz[i][2]; if (xyz[i][2] <= r) { down[cnt] = i; cnt++; } if (xyz[i][2] + r >= h) { up[i] = 1; } for (int j = 1; j < i; j++) { long long t1 = xyz[i][0] - xyz[j][0]; long long t2 = xyz[i][1] - xyz[j][1]; long long t3 = xyz[i][2] - xyz[j][2]; double dis = sqrt(t1 * t1 + t2 * t2 + t3 * t3); if (dis <= 2 * r){ arr[i][j] = arr[j][i] = 1; } } } int flag = 0; for (int i = 0; i < cnt; i++) { if (mark[down[i]] == 1) { continue; } else { mark[down[i]] = 1; } if (func(down[i]) == 1) { flag = 1; break; } } if (flag == 0) { cout << "No" << endl; } else { cout << "Yes" << endl; } } return 0; } ```
by 今年我15 @ 2021-07-15 20:07:13


@[今年我15](/user/540244) 谢谢!
by GUN_ @ 2021-07-23 20:15:16


|