// This code is AI-generated. (AI 生成的代码)
// NOIP2017 时间复杂度: parse nested F/E loops directly from DuckInfo. A loop
// F i x y contributes n to the nesting depth iff x is a number and y is "n";
// if x is "n" and y a number, or both numbers with x>y, the loop never runs and
// everything inside is dead. Track the live variable set for ERR detection.
typedef unsigned long long u64;
struct DuckInfo {
u64 abi; const char *in; u64 in_size; char *out; u64 out_limit, out_size;
char *err; u64 err_limit, err_size; const char *IB; u64 IB_limit;
char *OB; u64 OB_limit; u64 tsc;
} __attribute__((packed));
static const char *ip;
static char *op;
static inline const char *skip(const char *p) {
while (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') ++p;
return p;
}
int main(void) { return 0; }
void __libc_start_main(int (*mf)(int, char **, char **), int ac, char **av) {
(void)mf;
struct DuckInfo *d = (struct DuckInfo *)((u64 *)av)[29];
ip = d->in;
op = d->out;
{
const char *p = ip;
int t = 0;
while (*p >= '0' && *p <= '9') t = t * 10 + (*p++ - '0');
while (t--) {
p = skip(p);
int L = 0;
while (*p >= '0' && *p <= '9') L = L * 10 + (*p++ - '0');
p = skip(p); p += 2;
int expw = 0;
if (*p == 'n') { p += 2; while (*p >= '0' && *p <= '9') expw = expw * 10 + (*p++ - '0'); }
else ++p;
++p;
struct Frame { unsigned char v, isn, dead, contrib; } stk[128];
int top = 0, mask = 0, err = 0, dead = 0, cur = 0, maxc = 0;
for (int i = 0; i < L; ++i) {
p = skip(p);
char c = *p++;
if (c == 'F') {
++p;
int vi = *p++ - 'a';
++p;
int xnum = (*p != 'n'), xv = 0;
if (xnum) { xv = *p++ - '0'; if (*p >= '0' && *p <= '9') xv = xv * 10 + (*p++ - '0'); }
else ++p;
++p;
int ynum = (*p != 'n'), yv = 0;
if (ynum) { yv = *p++ - '0'; if (*p >= '0' && *p <= '9') yv = yv * 10 + (*p++ - '0'); }
else ++p;
int dd = 0, isn = 0;
if (!xnum && ynum) dd = 1;
else if (xnum && !ynum) isn = 1;
else if (xnum && ynum && xv > yv) dd = 1;
int b = 1 << vi;
if (mask & b) err = 1;
mask |= b;
int contrib = isn && (dead == 0);
stk[top].v = (unsigned char)vi; stk[top].isn = (unsigned char)isn;
stk[top].dead = (unsigned char)dd; stk[top].contrib = (unsigned char)contrib;
++top;
if (dd) ++dead;
if (contrib && ++cur > maxc) maxc = cur;
} else {
if (top == 0) err = 1;
else {
--top;
mask &= ~(1 << stk[top].v);
if (stk[top].contrib) --cur;
if (stk[top].dead) --dead;
}
}
}
if (top != 0) err = 1;
if (err) { *op++ = 'E'; *op++ = 'R'; *op++ = 'R'; }
else if (maxc == expw) { *op++ = 'Y'; *op++ = 'e'; *op++ = 's'; }
else { *op++ = 'N'; *op++ = 'o'; }
*op++ = '\n';
}
}
d->out_size = (u64)(op - d->out);
__asm__ volatile("mov $60,%%eax; xor %%edi,%%edi; syscall" ::: "rax", "rdi", "memory");
__builtin_unreachable();
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 5.5 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #2 | 3.72 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #3 | 3.36 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #4 | 3.34 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #5 | 3.62 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #6 | 3.84 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #7 | 3.89 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #8 | 4.13 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #9 | 3.78 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #10 | 3.57 us | 8 KB | Wrong Answer | Score: 0 | 显示更多 |