提交记录 47664
| 提交时间 |
评测时间 |
| 2026-09-13 01:05:37 |
2026-09-13 01:05:40 |
// This code is AI-generated. (AI 生成的代码)
// NOIP2017 奶酪: DFS over the sphere-intersection graph starting from spheres
// touching the bottom; succeed if a sphere touching the top is reached.
// Squared distances use 64-bit with term-by-term bounding (no __int128).
#include <stdio.h>
typedef long long ll;
static ll X[1005], Y[1005], Z[1005];
static char vis[1005];
static int n;
static ll h, r, r2;
static inline int hit(int i, int j) {
ll dx = X[i] - X[j], dy = Y[i] - Y[j], dz = Z[i] - Z[j];
ll ax = dx < 0 ? -dx : dx, ay = dy < 0 ? -dy : dy, az = dz < 0 ? -dz : dz;
ll q = ax * ax;
if (q > r2) return 0;
q += ay * ay;
if (q > r2) return 0;
return az * az <= r2 - q;
}
static int dfs(int u) {
vis[u] = 1;
if (Z[u] + r >= h) return 1;
for (int j = 0; j < n; j++)
if (!vis[j] && hit(u, j) && dfs(j)) return 1;
return 0;
}
static char buf[1 << 20], ob[1 << 12];
static char *gp;
int main() {
int len = (int)fread(buf, 1, sizeof(buf) - 1, stdin);
buf[len] = 0; gp = buf;
char *op = ob;
int T;
while (*gp < '0') gp++;
T = 0; while (*gp >= '0' && *gp <= '9') T = T * 10 + (*gp++ - '0');
while (T--) {
while (*gp < '0') gp++;
n = 0; while (*gp >= '0' && *gp <= '9') n = n * 10 + (*gp++ - '0');
while (*gp < '0') gp++;
h = 0; while (*gp >= '0' && *gp <= '9') h = h * 10 + (*gp++ - '0');
while (*gp < '0') gp++;
r = 0; while (*gp >= '0' && *gp <= '9') r = r * 10 + (*gp++ - '0');
r2 = 4 * r * r;
for (int i = 0; i < n; i++) {
vis[i] = 0;
while (*gp < '0' && *gp != '-') gp++;
int neg = (*gp == '-'); if (neg) gp++;
ll v = 0; while (*gp >= '0' && *gp <= '9') v = v * 10 + (*gp++ - '0');
X[i] = neg ? -v : v;
while (*gp < '0' && *gp != '-') gp++;
neg = (*gp == '-'); if (neg) gp++;
v = 0; while (*gp >= '0' && *gp <= '9') v = v * 10 + (*gp++ - '0');
Y[i] = neg ? -v : v;
while (*gp < '0' && *gp != '-') gp++;
neg = (*gp == '-'); if (neg) gp++;
v = 0; while (*gp >= '0' && *gp <= '9') v = v * 10 + (*gp++ - '0');
Z[i] = neg ? -v : v;
}
int ok = 0;
for (int i = 0; i < n && !ok; i++)
if (!vis[i] && Z[i] <= r && dfs(i)) ok = 1;
if (ok) { op[0]='Y'; op[1]='e'; op[2]='s'; op[3]='\n'; op += 4; }
else { op[0]='N'; op[1]='o'; op[2]='\n'; op += 3; }
}
fwrite(ob, 1, op - ob, stdout);
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 9.16 us | 32 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #2 | 8.42 us | 32 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #3 | 7.7 us | 32 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #4 | 12.91 us | 32 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #5 | 401.07 us | 120 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #6 | 1.028 ms | 200 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #7 | 2.687 ms | 356 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #8 | 2.129 ms | 320 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #9 | 2.313 ms | 564 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #10 | 2.026 ms | 560 KB | Accepted | Score: 10 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-09-24 18:07:41 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠