提交记录 47934


用户 题目 状态 得分 用时 内存 语言 代码长度
jiegec noi17b. 【NOI2017】蚯蚓排队 Accepted 100 554.887 ms 95712 KB C++17 3.40 KB
提交时间 评测时间
2026-09-13 11:03:56 2026-09-13 11:04:06
// This code is AI-generated. (AI 生成的代码)
#include<sys/auxv.h>
#pragma GCC optimize("Ofast,unroll-loops")
#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;
            { while (*ip && (unsigned char)*ip <= 32u) ip++; 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 #121.89 us28 KBAcceptedScore: 4

Testcase #215.56 us40 KBAcceptedScore: 4

Testcase #38.467 ms64 KBAcceptedScore: 4

Testcase #4158.08 us96 KBAcceptedScore: 4

Testcase #55.777 ms124 KBAcceptedScore: 4

Testcase #637.6 ms26 MB + 628 KBAcceptedScore: 4

Testcase #717.513 ms624 KBAcceptedScore: 4

Testcase #828.252 ms22 MB + 592 KBAcceptedScore: 4

Testcase #939.517 ms28 MB + 320 KBAcceptedScore: 4

Testcase #1091.615 ms24 MB + 372 KBAcceptedScore: 4

Testcase #11123.27 ms35 MB + 172 KBAcceptedScore: 4

Testcase #1248.623 ms31 MB + 216 KBAcceptedScore: 4

Testcase #1337.527 ms1 MB + 192 KBAcceptedScore: 4

Testcase #1460.799 ms41 MB + 1012 KBAcceptedScore: 4

Testcase #1570.908 ms45 MB + 576 KBAcceptedScore: 4

Testcase #16222.2 ms45 MB + 540 KBAcceptedScore: 4

Testcase #17262.086 ms55 MB + 88 KBAcceptedScore: 4

Testcase #18193.869 ms84 MB + 912 KBAcceptedScore: 4

Testcase #19219.473 ms93 MB + 336 KBAcceptedScore: 4

Testcase #2053.67 ms23 MB + 244 KBAcceptedScore: 4

Testcase #2178.483 ms2 MB + 340 KBAcceptedScore: 4

Testcase #22141.492 ms78 MB + 16 KBAcceptedScore: 4

Testcase #23149.062 ms79 MB + 380 KBAcceptedScore: 4

Testcase #24510.044 ms84 MB + 956 KBAcceptedScore: 4

Testcase #25554.887 ms93 MB + 480 KBAcceptedScore: 4


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