提交记录 29724


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_codex_260812 noip17d. 【NOIP2017】奶酪 Accepted 100 15.469 ms 36 KB C 4.70 KB
提交时间 评测时间
2026-08-12 01:12:26 2026-08-12 01:12:30
#ifndef DUCK_FASTIO_H
#define DUCK_FASTIO_H

typedef unsigned long duck_u64;
typedef long duck_i64;

typedef struct {
    duck_u64 abi_version;
    const char *stdin_ptr;
    duck_u64 stdin_size;
    char *stdout_ptr;
    duck_u64 stdout_limit;
    duck_u64 stdout_size;
    char *stderr_ptr;
    duck_u64 stderr_limit;
    duck_u64 stderr_size;
    const char *ib_ptr;
    duck_u64 ib_limit;
    char *ob_ptr;
    duck_u64 ob_limit;
    duck_u64 tsc_frequency;
} __attribute__((packed)) DuckInfo;

static __attribute__((always_inline)) inline DuckInfo *duck_info(long argc, char **argv) {
    char **p = argv + argc + 1;
    while (*p) ++p;
    duck_u64 *aux = (duck_u64 *)(p + 1);
    while (aux[0]) {
        if (aux[0] == 0x6b637564UL) return (DuckInfo *)aux[1];
        aux += 2;
    }
    return (DuckInfo *)0;
}

static __attribute__((always_inline)) inline duck_u64 duck_read_u64(const char **cursor) {
    const char *p = *cursor;
    while ((unsigned char)(*p - '0') > 9) ++p;
    duck_u64 value = 0;
    do {
        value = value * 10 + (unsigned char)(*p - '0');
        ++p;
    } while ((unsigned char)(*p - '0') <= 9);
    *cursor = p;
    return value;
}

static __attribute__((always_inline)) inline duck_i64 duck_read_i64(const char **cursor) {
    const char *p = *cursor;
    while (*p != '-' && (unsigned char)(*p - '0') > 9) ++p;
    int negative = *p == '-';
    p += negative;
    duck_u64 value = 0;
    do {
        value = value * 10 + (unsigned char)(*p - '0');
        ++p;
    } while ((unsigned char)(*p - '0') <= 9);
    *cursor = p;
    return negative ? -(duck_i64)value : (duck_i64)value;
}

static __attribute__((always_inline)) inline char *duck_write_u64(char *out, duck_u64 value) {
    char tmp[24];
    unsigned n = 0;
    do {
        tmp[n++] = (char)('0' + value % 10);
        value /= 10;
    } while (value);
    do *out++ = tmp[--n]; while (n);
    return out;
}

static __attribute__((always_inline)) inline char *duck_write_i64(char *out, duck_i64 value) {
    if (value < 0) {
        *out++ = '-';
        return duck_write_u64(out, (duck_u64)(-value));
    }
    return duck_write_u64(out, (duck_u64)value);
}

static __attribute__((always_inline, noreturn)) inline void duck_exit(void) {
    __asm__ volatile("mov $60,%%eax;xor %%edi,%%edi;syscall" ::: "rax", "rdi", "rcx", "r11", "memory");
    __builtin_unreachable();
}

#endif


typedef unsigned long u64;
typedef long i64;

static i64 xs[1000], ys[1000], zs[1000];
static unsigned short queue_nodes[1000];
static unsigned char reached[1000];

static __attribute__((always_inline)) inline int touches(unsigned a, unsigned b,
                                                          i64 limit, u64 limit2) {
    i64 dx = xs[a] - xs[b];
    if (dx < 0) dx = -dx;
    if (dx > limit) return 0;
    i64 dy = ys[a] - ys[b];
    if (dy < 0) dy = -dy;
    if (dy > limit) return 0;
    i64 dz = zs[a] - zs[b];
    if (dz < 0) dz = -dz;
    if (dz > limit) return 0;

    u64 sum = (u64)dx * (u64)dx;
    u64 part = (u64)dy * (u64)dy;
    if (part > limit2 - sum) return 0;
    sum += part;
    part = (u64)dz * (u64)dz;
    return part <= limit2 - sum;
}

__attribute__((noreturn))
void __libc_start_main(void *unused, long argc, char **argv) {
    (void)unused;
    DuckInfo *info = duck_info(argc, argv);
    const char *p = info->stdin_ptr;
    char *out = info->stdout_ptr;
    unsigned tests = (unsigned)duck_read_u64(&p);

    while (tests--) {
        unsigned n = (unsigned)duck_read_u64(&p);
        i64 h = (i64)duck_read_u64(&p);
        i64 r = (i64)duck_read_u64(&p);
        unsigned head = 0, tail = 0;
        int yes = 0;

        for (unsigned i = 0; i < n; ++i) {
            xs[i] = duck_read_i64(&p);
            ys[i] = duck_read_i64(&p);
            zs[i] = duck_read_i64(&p);
            reached[i] = 0;
            if (zs[i] <= r) {
                reached[i] = 1;
                queue_nodes[tail++] = (unsigned short)i;
                if (zs[i] + r >= h) yes = 1;
            }
        }

        i64 limit = r + r;
        u64 limit2 = (u64)limit * (u64)limit;
        while (!yes && head < tail) {
            unsigned u = queue_nodes[head++];
            for (unsigned v = 0; v < n; ++v) {
                if (reached[v] || !touches(u, v, limit, limit2)) continue;
                reached[v] = 1;
                queue_nodes[tail++] = (unsigned short)v;
                if (zs[v] + r >= h) {
                    yes = 1;
                    break;
                }
            }
        }

        if (yes) {
            __builtin_memcpy(out, "Yes\n", 4);
            out += 4;
        } else {
            __builtin_memcpy(out, "No\n", 3);
            out += 3;
        }
    }

    info->stdout_size = (u64)(out - info->stdout_ptr);
    duck_exit();
}

int main(void) {}

CompilationN/AN/ACompile OKScore: N/A

Testcase #14.12 us20 KBAcceptedScore: 10

Testcase #24.64 us20 KBAcceptedScore: 10

Testcase #34.59 us20 KBAcceptedScore: 10

Testcase #48.82 us20 KBAcceptedScore: 10

Testcase #52.551 ms36 KBAcceptedScore: 10

Testcase #612.666 ms36 KBAcceptedScore: 10

Testcase #713.731 ms36 KBAcceptedScore: 10

Testcase #815.469 ms36 KBAcceptedScore: 10

Testcase #911.481 ms36 KBAcceptedScore: 10

Testcase #1014.444 ms36 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2026-09-12 16:55:15 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠