提交记录 47193
| 用户 | 题目 | 状态 | 得分 | 用时 | 内存 | 语言 | 代码长度 |
|---|---|---|---|---|---|---|---|
| saffah_dsh_260814 | noi17a. 【NOI2017】整数 | Wrong Answer | 0 | 17.492 ms | 792 KB | C | 4.47 KB |
| 提交时间 | 评测时间 |
|---|---|
| 2026-08-20 02:03:36 | 2026-08-20 02:04:20 |
/* ph_batch.c — parse-only probe for the batch tokenizer (SSE2 scan + known-length SWAR convert).
* Output identical to ph_parse.c (query bits only), for judge parse-phase timing. */
#include <stdint.h>
#include <emmintrin.h>
#pragma GCC target("bmi")
#include <sys/auxv.h>
#include <unistd.h>
struct DuckInfo {
uint64_t abi_version;
const char *stdin_ptr; uint64_t stdin_size;
char *stdout_ptr; uint64_t stdout_limit; uint64_t stdout_size;
char *stderr_ptr; uint64_t stderr_limit; uint64_t stderr_size;
const char *IB_ptr; uint64_t IB_limit;
char *OB_ptr; uint64_t OB_limit;
uint64_t tsc_frequency;
} __attribute__((packed));
static const char *P;
static uint64_t O;
__attribute__((noreturn)) static void done(uint64_t olen, struct DuckInfo *di, char *out, int use_di){
if (use_di) di->stdout_size = olen;
else (void)!write(1, out, olen);
asm volatile("mov $60, %%eax; xor %%edi, %%edi; syscall" ::: "rax","rdi","memory");
__builtin_unreachable();
}
/* known-length SWAR convert of 1..8 ASCII digits at q (proven math from parse8) */
static inline unsigned cnv8(const char *q, int L){
unsigned long long x;
__builtin_memcpy(&x, q, 8);
unsigned long long d = __builtin_bswap64(x - 0x3030303030303030ULL);
d >>= 64 - (L << 3);
unsigned long long t = (d * 0x010AULL) & 0xFF00FF00FF00FF00ULL;
t >>= 8;
unsigned long long t2 = t * 0x00010064ULL;
return (unsigned)(((t2 >> 16) & 0xFFFFULL) + 10000ULL * ((t2 >> 48) & 0xFFFFULL));
}
/* 16-bit bitmask: bit i set iff byte i > 0x20 (token char: digit or '-') */
static inline unsigned chmask16(const char *p){
__m128i x = _mm_loadu_si128((const __m128i*)p);
__m128i g = _mm_cmpgt_epi8(x, _mm_set1_epi8(0x20));
return (unsigned)_mm_movemask_epi8(g);
}
int main(){
struct DuckInfo *di = (struct DuckInfo*)getauxval(0x6b637564);
static char lbuf[1<<24];
static char obuf[1<<22];
char *out;
int use_di = 0;
const char *end;
if (di && di->abi_version >= 1 && di->stdin_ptr && di->stdout_ptr){
P = di->stdin_ptr; out = di->stdout_ptr; use_di = 1;
end = di->stdin_ptr + di->stdin_size;
} else {
long n2 = 0, t;
while (n2 < (long)sizeof(lbuf) && (t = read(0, lbuf + n2, sizeof(lbuf) - n2)) > 0) n2 += t;
lbuf[n2] = 0; P = lbuf; out = obuf;
end = lbuf + n2;
}
/* header: 4 numbers */
int n = 0;
while (*P > ' '){ n = n*10 + (*P - '0'); P++; }
while (*P <= ' ') P++;
while (*P > ' ') P++;
while (*P <= ' ') P++;
while (*P > ' ') P++;
while (*P <= ' ') P++;
while (*P > ' ') P++;
while (*P <= ' ') P++;
long acc = 0;
int st = 0; unsigned opv = 0, av = 0; int aneg = 0;
int ops_done = 0;
while (P + 32 <= end && ops_done < n){
unsigned tc = chmask16(P) | (chmask16(P + 16) << 16);
int pos = 0;
while (pos < 16 && ops_done < n){
unsigned L = __builtin_ctz(~tc >> pos);
if (L == 0){ pos++; continue; }
if (L > 11){ P += pos; goto scalar_tail; }
const char *q = P + pos;
int neg = 0;
if (*q == '-'){ neg = 1; q++; L--; }
unsigned v;
if (L <= 8) v = cnv8(q, (int)L);
else {
v = cnv8(q, 8);
v = v * 10u + (unsigned)(q[8] - '0');
if (L == 10) v = v * 10u + (unsigned)(q[9] - '0');
}
switch (st){
case 0: opv = v; st = 1; break;
case 1:
if (opv == 1){ av = v; aneg = neg; st = 2; }
else { acc += v; out[O++] = (char)('0' + (acc & 1)); out[O++] = '\n'; st = 0; ops_done++; }
break;
default:
if (aneg) acc -= (long)av + v; else acc += (long)av + v;
st = 0; ops_done++; break;
}
pos += (int)L + 1 + neg;
}
P += pos;
}
scalar_tail:
while (ops_done < n){
while (*P <= ' ') P++;
int neg = 0;
if (*P == '-'){ neg = 1; P++; }
unsigned v = 0;
while (*P > ' '){ v = v*10 + (unsigned)(*P - '0'); P++; }
switch (st){
case 0: opv = v; st = 1; break;
case 1:
if (opv == 1){ av = v; aneg = neg; st = 2; }
else { acc += v; out[O++] = (char)('0' + (acc & 1)); out[O++] = '\n'; st = 0; ops_done++; }
break;
default:
if (aneg) acc -= (long)av + v; else acc += (long)av + v;
st = 0; ops_done++; break;
}
}
done(O, di, out, use_di);
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 6.69 us | 12 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #2 | 7.36 us | 12 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #3 | 37.38 us | 12 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 67.36 us | 12 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #5 | 95.59 us | 12 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #6 | 134.45 us | 16 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #7 | 163.96 us | 16 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #8 | 175.71 us | 16 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #9 | 613.16 us | 28 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #10 | 822.96 us | 36 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #11 | 1.029 ms | 48 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #12 | 1.051 ms | 48 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #13 | 1.234 ms | 52 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #14 | 3.461 ms | 128 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #15 | 4.882 ms | 188 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #16 | 6.973 ms | 248 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #17 | 8.836 ms | 308 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #18 | 10.457 ms | 368 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #19 | 12.194 ms | 428 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #20 | 12.432 ms | 792 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #21 | 15.925 ms | 548 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #22 | 16.288 ms | 564 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #23 | 14.691 ms | 480 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #24 | 17.233 ms | 600 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #25 | 17.492 ms | 604 KB | Wrong Answer | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-08-22 12:13:03 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠