提交记录 47759


用户 题目 状态 得分 用时 内存 语言 代码长度
jiegec noi17b. 【NOI2017】蚯蚓排队 Runtime Error 0 29.411 ms 10592 KB C++17 3.32 KB
提交时间 评测时间
2026-09-13 02:24:55 2026-09-13 02:25:03
// This code is AI-generated. (AI 生成的代码)
#include<sys/auxv.h>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int k=50,mod=998244353;
int n,m,len,y[10000002],t[8][20000002];
long long ans;
char ch[10000002];
typedef struct{
    int w,las,nex;
}P;
P p[200002];
struct DuckInfo {
    unsigned long abi; const char *in; unsigned long in_size;
    char *out; unsigned long out_limit, out_size;
    char *err; unsigned long err_limit, err_size;
    const char *IB; unsigned long IB_limit; char *OB; unsigned long OB_limit; unsigned long tsc;
} __attribute__((packed));
static const char *ip; static char *op;
int read()
{
    const char *p = ip;
    while ((unsigned)(*p - '0') > 9u && *p != '-') p++;
    int w = 1;
    if (*p == '-') { w = -1; p++; }
    int data = 0;
    while ((unsigned)(*p - '0') <= 9u) data = data * 10 + (*p++ - '0');
    ip = p;
    return data * w;
}
static void wr(long long v) {
    if (v < 0) { *op++ = '-'; v = -v; }
    char t[24]; int k = 0;
    if (!v) t[k++] = '0';
    while (v) { t[k++] = (char)('0' + v % 10); v /= 10; }
    while (k) *op++ = t[--k];
    *op++ = '\n';
}
int main()
{
    struct DuckInfo *d = (struct DuckInfo *)getauxval(0x6b637564UL);
    ip = d->in; op = d->out;
    n=read();m=read();
    for (int i=1;i<=n;i++)
    {
        p[i].w=read();p[i].las=p[i].nex=-1;
        if (!t[p[i].w][0])t[p[i].w][0]=++len;
        t[0][t[p[i].w][0]]++;
    }
    while(m--)
    {
        int u;
        u=read();
        if (u==1)
        {
            int a,b,c,root;bool u;
            a=read();b=read();
            p[a].nex=b;p[b].las=a;
            for (int i=a;i!=-1;i=p[i].las)
            {
                c=u=root=0;
                for (int j=i;c<k&&j!=-1;j=p[j].nex)
                {
                    if (!t[p[j].w][root])
                    {
                        t[p[j].w][root]=++len;
                        if (t[7][root]==-1 || !t[p[j].w][t[7][root]])
                        t[7][len]=-1;
                        else t[7][len]=t[p[j].w][t[7][root]];
                    }
                    root=t[p[j].w][root];
                    if (j==b)u=1;t[0][root]+=u;
                    c++;
                }
                if (!u)break;
            }
        }
        else if (u==2)
        {
            int a,b,c,root;bool u;
            a=read();b=p[a].nex;
            for (int i=a;i!=-1;i=p[i].las)
            {
                c=u=0;root=0;
                for (int j=i;c<k&&j!=-1;j=p[j].nex)
                {
                    root=t[p[j].w][root];
                    if (j==b)u=1;t[0][root]-=u;
                    c++;
                }
                if (!u)break;
            }
            p[a].nex=p[b].las=-1;
        }
        else
        {
            int a,l,root=0;ans=0;
            { char *cp = ch; while ((unsigned char)*ip > 32u) *cp++ = *ip++; *cp = 0; } a=read(); l=(int)strlen(ch);
            for (int i=0;i<a;i++)
            {
                root=t[ch[i]-48][root];if (!root)goto ccj;
            }
            ans=t[0][root];
            for (int i=a;i<l;i++)
            {
                root=t[7][root];if (root<0){ans=0;goto ccj;}
                root=t[ch[i]-48][root];if (!root){ans=0;goto ccj;}
                ans=ans*t[0][root]%mod;
            }
            ccj:wr(ans);
        }
    }
    d->out_size = (unsigned long)(op - d->out);
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #17.53 us24 KBRuntime ErrorScore: 0

Testcase #210.04 us32 KBRuntime ErrorScore: 0

Testcase #346.02 us52 KBRuntime ErrorScore: 0

Testcase #490.73 us64 KBRuntime ErrorScore: 0

Testcase #5142.46 us56 KBRuntime ErrorScore: 0

Testcase #6644.43 us632 KBRuntime ErrorScore: 0

Testcase #75.668 ms612 KBRuntime ErrorScore: 0

Testcase #86.511 ms2 MB + 800 KBRuntime ErrorScore: 0

Testcase #97.194 ms3 MB + 376 KBRuntime ErrorScore: 0

Testcase #106.659 ms3 MB + 160 KBRuntime ErrorScore: 0

Testcase #117.124 ms3 MB + 484 KBRuntime ErrorScore: 0

Testcase #121.899 ms1 MB + 204 KBRuntime ErrorScore: 0

Testcase #139.461 ms1 MB + 176 KBRuntime ErrorScore: 0

Testcase #1413.583 ms5 MB + 220 KBRuntime ErrorScore: 0

Testcase #1512.346 ms4 MB + 560 KBRuntime ErrorScore: 0

Testcase #1610.95 ms3 MB + 624 KBRuntime ErrorScore: 0

Testcase #1716.279 ms7 MB + 504 KBRuntime ErrorScore: 0

Testcase #18870.66 us2 MB + 336 KBRuntime ErrorScore: 0

Testcase #19868.87 us2 MB + 332 KBRuntime ErrorScore: 0

Testcase #204.648 ms2 MB + 360 KBRuntime ErrorScore: 0

Testcase #2121.318 ms2 MB + 316 KBRuntime ErrorScore: 0

Testcase #2228.579 ms9 MB + 608 KBRuntime ErrorScore: 0

Testcase #2319.965 ms4 MB + 976 KBRuntime ErrorScore: 0

Testcase #2429.411 ms10 MB + 352 KBRuntime ErrorScore: 0

Testcase #2522.873 ms6 MB + 460 KBRuntime ErrorScore: 0


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