提交记录 49789


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_v41_0919 1000i. 【传统题】 A+B Problem Accepted 100 11.74 us 12 KB C++17 2.73 KB
提交时间 评测时间
2026-09-19 16:11:53 2026-09-19 16:13:15
// 1000i A+B (n pairs): minimal startup + SWAR parsing + 2-digit-table printing,
// writing straight into the DuckInfo stdin/stdout buffers.
typedef unsigned long long u64;

struct DI {
    u64 abi; const char *in; u64 insz; char *out; u64 outlim; u64 outsz;
    char *err; u64 errlim; u64 errsz; const char *IB; u64 IBlim; char *OB;
    u64 OBlim; u64 tscfreq;
} __attribute__((packed));

static const char DIG2[201] =
 "00010203040506070809101112131415161718192021222324252627282930313233343536373839"
 "40414243444546474849505152535455565758596061626364656667686970717273747576777879"
 "8081828384858687888990919293949596979899";

static const char *g_end;

static inline int rdint(const char *&p) {
    unsigned char c = (unsigned char)*p;
    while (c != '-' && (c < '0' || c > '9')) c = (unsigned char)*++p;
    int neg = 0;
    if (c == '-') { neg = 1; c = (unsigned char)*++p; }
    unsigned v = 0;
    if (p + 8 <= g_end) {
        u64 w;
        __builtin_memcpy(&w, p, 8);
        u64 d = w - 0x3030303030303030ULL;
        if (!((d | (w + 0x4646464646464646ULL)) & 0x8080808080808080ULL)) {
            u64 t = (d * 10 + (d >> 8)) & 0x00FF00FF00FF00FFULL;
            t = (t * 100 + (t >> 16)) & 0x0000FFFF0000FFFFULL;
            v = (unsigned)(t * 10000 + (t >> 32));
            p += 8;
            c = (unsigned char)*p;
        }
    }
    while (c >= '0') { v = v * 10 + (c - '0'); c = (unsigned char)*++p; }
    return neg ? -(int)v : (int)v;
}

static inline void wrint(int v, char *&o) {
    unsigned uv;
    if (v < 0) { *o++ = '-'; uv = (unsigned)(-(long long)v); } else uv = (unsigned)v;
    char t[12];
    char *q = t + 11;
    while (uv >= 100) { unsigned r = uv % 100; uv /= 100; q -= 2; q[0] = DIG2[2 * r]; q[1] = DIG2[2 * r + 1]; }
    if (uv >= 10) { q -= 2; q[0] = DIG2[2 * uv]; q[1] = DIG2[2 * uv + 1]; }
    else *--q = (char)('0' + uv);
    while (q < t + 11) *o++ = *q++;
    *o++ = '\n';
}

extern "C" int __libc_start_main(int (*m)(int, char **, char **), int argc, char **argv,
                                 void (*i)(void), void (*f)(void), void (*l)(void)) {
    char **env = argv + argc + 1;
    while (*env) env++;
    u64 *aux = (u64 *)(env + 1);
    u64 di = 0;
    for (u64 *p = aux; p[0]; p += 2) if (p[0] == 0x6b637564ULL) { di = p[1]; break; }
    const char *in = *(const char **)(di + 8);
    g_end = in + *(u64 *)(di + 16);
    char *out = *(char **)(di + 24);
    char *o = out;
    int n = rdint(in);
    while (n-- > 0) { int a = rdint(in); int b = rdint(in); wrint(a + b, o); }
    *(u64 *)(di + 40) = (u64)(o - out);
    register long rax __asm__("rax") = 60;
    register long rdi __asm__("rdi") = 0;
    __asm__ volatile("syscall" :: "a"(rax), "D"(rdi) : "rcx", "r11", "memory");
    __builtin_unreachable();
}
int main() { return 0; }

CompilationN/AN/ACompile OKScore: N/A

Testcase #111.74 us12 KBAcceptedScore: 100


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