提交记录 3568
用户 | 题目 | 状态 | 得分 | 用时 | 内存 | 语言 | 代码长度 |
---|---|---|---|---|---|---|---|
1124828077 | noi17b. 【NOI2017】蚯蚓排队 | Accepted | 100 | 584.255 ms | 95800 KB | C++ | 2.47 KB |
提交时间 | 评测时间 |
---|---|
2018-07-16 14:35:32 | 2020-07-31 21:19:41 |
#include<cstdio>
#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];
int read()
{
int data=0,w=1; char ch=0;
while(ch!='-' && (ch<'0' || ch>'9')) ch=getchar();
if(ch=='-'){w=-1;ch=getchar();}
while(ch>='0' && ch<='9'){data=data*10+ch-'0';ch=getchar();}
return data*w;
}
int main()
{
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;
scanf("%s",ch);a=read();l=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:printf("%lld\n",ans);
}
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 267.39 us | 32 KB | Accepted | Score: 4 | 显示更多 |
Testcase #2 | 25.98 us | 40 KB | Accepted | Score: 4 | 显示更多 |
Testcase #3 | 8.779 ms | 64 KB | Accepted | Score: 4 | 显示更多 |
Testcase #4 | 183.8 us | 96 KB | Accepted | Score: 4 | 显示更多 |
Testcase #5 | 5.982 ms | 124 KB | Accepted | Score: 4 | 显示更多 |
Testcase #6 | 38.998 ms | 26 MB + 604 KB | Accepted | Score: 4 | 显示更多 |
Testcase #7 | 19.038 ms | 624 KB | Accepted | Score: 4 | 显示更多 |
Testcase #8 | 29.551 ms | 22 MB + 568 KB | Accepted | Score: 4 | 显示更多 |
Testcase #9 | 40.797 ms | 28 MB + 240 KB | Accepted | Score: 4 | 显示更多 |
Testcase #10 | 99.857 ms | 24 MB + 352 KB | Accepted | Score: 4 | 显示更多 |
Testcase #11 | 131.755 ms | 35 MB + 312 KB | Accepted | Score: 4 | 显示更多 |
Testcase #12 | 51.353 ms | 31 MB + 244 KB | Accepted | Score: 4 | 显示更多 |
Testcase #13 | 40.374 ms | 1 MB + 192 KB | Accepted | Score: 4 | 显示更多 |
Testcase #14 | 63.276 ms | 42 MB + 48 KB | Accepted | Score: 4 | 显示更多 |
Testcase #15 | 73.311 ms | 45 MB + 596 KB | Accepted | Score: 4 | 显示更多 |
Testcase #16 | 237.897 ms | 45 MB + 556 KB | Accepted | Score: 4 | 显示更多 |
Testcase #17 | 277.741 ms | 55 MB + 32 KB | Accepted | Score: 4 | 显示更多 |
Testcase #18 | 254.339 ms | 85 MB + 124 KB | Accepted | Score: 4 | 显示更多 |
Testcase #19 | 279.844 ms | 93 MB + 484 KB | Accepted | Score: 4 | 显示更多 |
Testcase #20 | 59.656 ms | 23 MB + 216 KB | Accepted | Score: 4 | 显示更多 |
Testcase #21 | 83.805 ms | 2 MB + 344 KB | Accepted | Score: 4 | 显示更多 |
Testcase #22 | 145.769 ms | 77 MB + 944 KB | Accepted | Score: 4 | 显示更多 |
Testcase #23 | 153.836 ms | 79 MB + 424 KB | Accepted | Score: 4 | 显示更多 |
Testcase #24 | 540.288 ms | 84 MB + 896 KB | Accepted | Score: 4 | 显示更多 |
Testcase #25 | 584.255 ms | 93 MB + 568 KB | Accepted | Score: 4 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:34:13 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠