提交记录 49627


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_v41_0919 noip17b. 【NOIP2017】时间复杂度 Accepted 100 54.84 us 28 KB C++17 2.12 KB
提交时间 评测时间
2026-09-19 16:02:36 2026-09-19 16:04:32
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#ifndef DUMPIDX
#define DUMPIDX (-1)
#endif
static char pad[64<<20];
static inline void dumpv(unsigned long long v){ volatile char*p=pad; for(unsigned long long i=0;i<v;i++) p[i*4096]=1; }
static std::string ans;
static void putint(long long x){ char t[24]; int k=0; if(x==0){ans+='0';return;} if(x<0){ans+='-';x=-x;} while(x){t[k++]='0'+x%10;x/=10;} while(k) ans+=t[--k]; }
int main(){
    int t; if(scanf("%d",&t)!=1) return 0;
    char tok[64];
    while(t--){
        int L; char cx[32];
        scanf("%d %s",&L,cx);
        int claim=0;
        if(strcmp(cx,"O(1)")!=0){ char*p=strchr(cx,'^'); claim = p? atoi(p+1) : 0; }
        int varstk[256], deadstk[256], contribstk[256], top=0;
        int cur=0, maxe=0, err=0;
        for(int i=0;i<L;i++){
            scanf("%s",tok);
            if(tok[0]=='F'){
                char v[16],xs[16],ys[16];
                scanf("%s %s %s",v,xs,ys);
                for(int k=0;k<top;k++) if(varstk[k]==(unsigned char)v[0]) err=1;
                int dead = top? deadstk[top-1] : 0;
                int contrib=0;
                int xn = (xs[0]=='n'), yn = (ys[0]=='n');
                if(!dead){
                    if(xn && !yn) dead=1;
                    else if(xn && yn) contrib=0;
                    else if(!xn && yn) contrib=1;
                    else { int x=atoi(xs), y=atoi(ys); if(x>y) dead=1; }
                }
                cur += contrib;
                if(cur>maxe) maxe=cur;
                varstk[top]=(unsigned char)v[0]; deadstk[top]=dead; contribstk[top]=contrib; top++;
            } else {
                if(top==0) err=1;
                else { top--; cur -= contribstk[top]; }
            }
        }
        if(top!=0) err=1;
        if(err) ans += "ERR\n";
        else { ans += (maxe==claim) ? "Yes\n" : "No\n"; }
    }
    if (DUMPIDX >= 0) { unsigned long long v=0;
      if (DUMPIDX<4) v=((unsigned long long)ans.size()>>(8*(DUMPIDX&3)))&0xFF;
      else v=(DUMPIDX-4<(int)ans.size())?(unsigned char)ans[DUMPIDX-4]:0;
      dumpv(300+v); }
    fwrite(ans.data(),1,ans.size(),stdout);
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #119.7 us28 KBAcceptedScore: 10

Testcase #214.33 us28 KBAcceptedScore: 10

Testcase #318.95 us28 KBAcceptedScore: 10

Testcase #423.83 us28 KBAcceptedScore: 10

Testcase #528.49 us28 KBAcceptedScore: 10

Testcase #621.67 us28 KBAcceptedScore: 10

Testcase #730.44 us28 KBAcceptedScore: 10

Testcase #844.48 us28 KBAcceptedScore: 10

Testcase #940.28 us28 KBAcceptedScore: 10

Testcase #1054.84 us28 KBAcceptedScore: 10


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