提交记录 31416


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_260814 noip17b. 【NOIP2017】时间复杂度 Accepted 100 5.93 us 8 KB C++ 3.35 KB
提交时间 评测时间
2026-08-14 01:52:18 2026-08-14 01:52:22
typedef unsigned long long u64;

static inline const char* skipnl(const char* p) {
    while (*p==' '||*p=='\n'||*p=='\r'||*p=='\t') ++p;
    return p;
}

int solve(const char* in, char* out) {
    const char* p = in;
    char* o = out;
    int t = 0;
    while (*p>='0'&&*p<='9') { t=t*10+(*p-'0'); ++p; }
    while (t--) {
        p = skipnl(p);
        int L = 0;
        while (*p>='0'&&*p<='9') { L=L*10+(*p-'0'); ++p; }
        p = skipnl(p); ++p; ++p; // "O("
        int expw = 0;
        if (*p == 'n') { ++p; ++p; while (*p>='0'&&*p<='9'){expw=expw*10+(*p-'0');++p;} }
        else { ++p; }
        ++p; // ')'
        struct { unsigned char var; unsigned char isn; unsigned char dead; unsigned char contrib; } stk[128];
        int top = 0, mask = 0, err = 0, dead = 0, cur = 0, maxc = 0;
        for (int i = 0; i < L; ++i) {
            p = skipnl(p);
            char c = *p++;
            if (c == 'F') {
                ++p; // space
                int vi = (*p++ - 'a');
                ++p; // space
                int xisnum = (*p != 'n');
                int xv = 0;
                if (xisnum) { xv=*p-'0'; ++p; if (*p>='0'&&*p<='9'){xv=xv*10+(*p-'0');++p;} }
                else ++p;
                ++p; // space
                int yisnum = (*p != 'n');
                int yv = 0;
                if (yisnum) { yv=*p-'0'; ++p; if (*p>='0'&&*p<='9'){yv=yv*10+(*p-'0');++p;} }
                else ++p;
                int this_dead = 0, this_isn = 0;
                if (!xisnum && yisnum) this_dead = 1;
                else if (xisnum && !yisnum) this_isn = 1;
                else if (xisnum && yisnum) { if (xv > yv) this_dead = 1; }
                int b = 1 << vi;
                if (mask & b) err = 1;
                mask |= b;
                int contrib = this_isn && (dead == 0);
                stk[top].var = vi; stk[top].isn = this_isn; stk[top].dead = this_dead; stk[top].contrib = contrib;
                ++top;
                if (this_dead) ++dead;
                if (contrib) { ++cur; if (cur > maxc) maxc = cur; }
            } else {
                if (top == 0) err = 1;
                else {
                    --top;
                    mask &= ~(1 << stk[top].var);
                    if (stk[top].contrib) --cur;
                    if (stk[top].dead) --dead;
                }
            }
        }
        if (top != 0) err = 1;
        if (err) { *o++='E'; *o++='R'; *o++='R'; }
        else if (maxc == expw) { *o++='Y'; *o++='e'; *o++='s'; }
        else { *o++='N'; *o++='o'; }
        *o++='\n';
    }
    return (int)(o - out);
}

#ifdef LOCAL_TEST
#include <cstdio>
int main() {
    char in[1<<16]; int n = fread(in,1,sizeof in, stdin); in[n]=0;
    char out[1<<12];
    int len = solve(in, out);
    fwrite(out,1,len,stdout);
    return 0;
}
#else
struct di { u64 ver; const char *in; u64 insz; char *out; u64 outlim; u64 outsz; };
#define AT_DUCK 0x6b637564ULL
extern "C" void __libc_start_main(
    int (*m)(int,char**,char**), int argc, char **argv,
    void (*i)(void), void (*f)(void), void (*r)(void), void *se)
{
    char **p = argv + argc + 1; while (*p) ++p; ++p;
    struct di *D = 0;
    while (p[0]) { if (p[0]==(char*)AT_DUCK){D=(struct di*)p[1];break;} p+=2; }
    int len = solve(D->in, D->out);
    D->outsz = (u64)len;
    __asm__ volatile("mov $60,%rax; xor %rdi,%rdi; syscall");
    __builtin_unreachable();
}
int main(){ return 0; }
#endif

CompilationN/AN/ACompile OKScore: N/A

Testcase #13.52 us8 KBAcceptedScore: 10

Testcase #23.19 us8 KBAcceptedScore: 10

Testcase #33.52 us8 KBAcceptedScore: 10

Testcase #43.94 us8 KBAcceptedScore: 10

Testcase #54.04 us8 KBAcceptedScore: 10

Testcase #63.36 us8 KBAcceptedScore: 10

Testcase #74.32 us8 KBAcceptedScore: 10

Testcase #84.79 us8 KBAcceptedScore: 10

Testcase #94.62 us8 KBAcceptedScore: 10

Testcase #105.93 us8 KBAcceptedScore: 10


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