QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#642071#5311. Master of BothIcedpiggy#WA 47ms44572kbC++14845b2024-10-15 09:38:422024-10-15 09:38:43

Judging History

你现在查看的是最新测评结果

  • [2024-10-15 09:38:43]
  • 评测
  • 测评结果:WA
  • 用时:47ms
  • 内存:44572kb
  • [2024-10-15 09:38:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define i64 long long
#define i128 __int128
inline i64 rd()
{
	i64 num=0;char ch=getchar();bool op=0;
	for(;!isdigit(ch);ch=getchar())if(ch=='-')op=1;
	for(;isdigit(ch);ch=getchar())num=num*10+(ch-'0');
	return op?-num:num;
}

const int M=1e6+10;
const int w=25;

int n,q;
char a[M];
int s[M][26],c[M][26];int tot=0;
i64 cnt[26][26];
inline void ins()
{
	int p=0;
	for(int i=0;a[i];i++)
	{
		int ch=a[i]-'a';
		for(int k=0;k<=w;k++)cnt[k][ch]+=c[p][k];
		if(!s[p][ch])s[p][ch]=++tot;
		c[p][ch]++,p=s[p][ch];
	}
}
int main()
{
	n=rd(),q=rd();
	for(int i=1;i<=n;i++)
		scanf("%s",a),ins();
	for(;q;q--)
	{
		scanf("%s",a);i64 Ans=0;
		for(int i=w;i>=0;i--)
			for(int j=i-1;j>=0;j--)
				Ans+=cnt[a[i]-'a'][a[j]-'a'];
		printf("%lld\n",Ans);
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3744kb

input:

5 3
aac
oiputata
aaa
suikabudada
aba
abcdefghijklmnopqrstuvwxyz
qwertyuiopasdfghjklzxcvbnm
aquickbrownfxjmpsvethlzydg

output:

4
3
4

result:

ok 3 number(s): "4 3 4"

Test #2:

score: 0
Accepted
time: 3ms
memory: 44572kb

input:

100 100
spkfvrbkfsspmnlgrdojwdqutknvzejorqxsmfgbfrhpxkrrtravhmxenjrzypkxounrbantpkaezlcnudjmwxpgqakfoxcmdjcygujdtpluovbisxmklkzzuuyziapzyrszcggjkzrwmtyolnbobubbezdwmumyzyhaogiiolictzjpxbyaamecytpnyzxlumxjkzyfavxlzdwtgrxtqcnddzfocznitlaxlpcceuelqlbmyzetlpaivxnuvuctsbjbaulmbmkangqahpdojqimvmcugjeczkgx...

output:

2368
2693
2179
2466
2435
2370
2604
2468
2335
2268
2686
2781
2538
2208
2386
2539
2728
2383
2248
2372
2446
2266
2290
2688
2602
2515
2634
2558
2598
2632
2763
2255
2557
2579
2367
2516
2676
2273
2429
2556
2576
2635
2422
2829
2362
2552
2377
2261
2603
2516
2298
2282
2520
2333
2505
2287
2261
2476
2791
2328
...

result:

ok 100 numbers

Test #3:

score: -100
Wrong Answer
time: 47ms
memory: 34028kb

input:

500000 5
ru
x
tb
s
e
w
e
m
l
b
g
zr
jp
h
js
xk
fjwtk
wtkem
o
ev
a
a
x
sy
dh
y
kkdcxfr
hgq
j
k
xr
s
cvwbrlk
u
u
x
wtvgef
dzxsk
qv
gxl
g
m
rpl
ldp
q
lc
dk
g
k
im
o
yhn
z
a
knc
tyv
mz
ak
qdhq
c
niw
o
j
heu
w
g
e
kt
n
inqt
i
al
q
ebphky
sv
m
mry
oj
cl
j
r
sf
vpd
u
rio
sfkg
m
el
s
zs
g
o
e
njp
r
xczcm
gh...

output:

60698136185
60730188741
60672616223
60740783841
60714178255

result:

wrong answer 1st numbers differ - expected: '61908555824', found: '60698136185'