QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#223782#7060. Paper Gradingveg#AC ✓844ms46512kbC++142.3kb2023-10-22 16:55:502023-10-22 16:55:51

Judging History

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

  • [2023-10-22 16:55:51]
  • 评测
  • 测评结果:AC
  • 用时:844ms
  • 内存:46512kb
  • [2023-10-22 16:55:50]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const int hsmod=19260817;
const int maxn=2e5+10;
const int N=2e5;
const int maxsq=450;

ull hs[maxn];
vector<ull> a[maxn];
string s[maxn];
int bar[maxn];
int bel[maxn];
unordered_map<ull,int> sum[maxsq][maxsq];
int L[maxsq];
int R[maxsq];
char t[maxn];
struct Node
{
	ull hs;
	int opt,l,r,len;
}req[maxn];

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		cin>>s[i];
	for(int i=1;i<=m;i++)
	{
		int opt;
		scanf("%d",&opt);
		if(opt==2)
		{
			scanf("%s%d",t+1,&req[i].len);
			bar[req[i].len]=1;
			ull tmp=0;
			for(int j=1;j<=req[i].len;j++) tmp=tmp*hsmod+t[j];
			req[i].hs=tmp;
		}
		req[i].opt=opt;
		scanf("%d%d",&req[i].l,&req[i].r);
	}
	int cnt=0,sq=sqrt(n);
	vector<int> vec;
	for(int i=1;i<=N;i++) if(bar[i]) bar[i]=cnt++,vec.push_back(i);
	for(int i=1;i<=n;i++)
	{
		ull tmp=0;
		bel[i]=(i-1)/sq+1;
		for(int j=0,k=0;j<s[i].size()&&k<cnt;j++)
		{
			tmp=tmp*hsmod+s[i][j];
			if(j+1==vec[k])
				a[i].push_back(tmp),sum[bel[i]][k++][tmp]++;
		}
	}
	for(int i=1;i<=bel[n];i++) L[i]=(i-1)*sq+1,R[i]=min(i*sq,n);
	for(int i=1;i<=m;i++)
	{
		if(req[i].opt==1)
		{
			for(int j=0;j<a[req[i].l].size();j++)
				sum[bel[req[i].l]][j][a[req[i].l][j]]--,sum[bel[req[i].r]][j][a[req[i].l][j]]++;
			for(int j=0;j<a[req[i].r].size();j++)
				sum[bel[req[i].r]][j][a[req[i].r][j]]--,sum[bel[req[i].l]][j][a[req[i].r][j]]++;
			swap(a[req[i].l],a[req[i].r]);
		}
		else if(!req[i].len) printf("%d\n",req[i].r-req[i].l+1);
		else if(bel[req[i].l]==bel[req[i].r])
		{
			int ans=0;
			for(int j=req[i].l;j<=req[i].r;j++)
				if(bar[req[i].len]<a[j].size()&&a[j][bar[req[i].len]]==req[i].hs)
					ans++;
			printf("%d\n",ans);
		}
		else
		{
			int ans=0;
			for(int j=req[i].l;j<=R[bel[req[i].l]];j++)
				if(bar[req[i].len]<a[j].size()&&a[j][bar[req[i].len]]==req[i].hs)
					ans++;
			for(int j=req[i].r;j>=L[bel[req[i].r]];j--)
				if(bar[req[i].len]<a[j].size()&&a[j][bar[req[i].len]]==req[i].hs)
					ans++;
			for(int j=bel[req[i].l]+1;j<bel[req[i].r];j++)
				if(sum[j][bar[req[i].len]].count(req[i].hs))
					ans+=sum[j][bar[req[i].len]][req[i].hs];
			printf("%d\n",ans);
		}
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 29100kb

input:

3 4
aaa
bbb
aac
2 aasdd 2 1 3
2 aab 1 1 2
1 2 3
2 aat 2 1 2

output:

2
1
2

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 6ms
memory: 28712kb

input:

203 280
weoswjrqbctjwprpwhskdmupkrnvwqrzsgjgd
raxdectwomdlkriivpotxka
vjeyfjhpka
vjeyfjhpkr
vjeyfjhpky
uxe
ykytzfawioj
raxdectwomdlkriivpotxkw
vjeyfjhpkd
pioilxbjbxbgzkcwjlk
rqtxnvrllmaoj
raxdectwomdlkriivpotxko
vjeyfjhpka
dsf
uxj
fbpcblrbxqiyghzancwdoxhgglzuprfyggbdrscclmskyigukfixxgczalqahwbfqtzfi...

output:

8
3
6
0
13
3
3
3
1
4
11
7
6
0
3
18
2
1
8
10
11
2
22
4
7
2
1
0
24
3
1
5
3
3
11
5
5
5
2
1
4
2
9
6
18
3
4
5
4
0
2
84
10
8
1
11
8
3
3
6
1
0
1
7
4
8
0
2
0
3
3
8
14
16
6
3
1
13
3
27
1
6
4
0
0
3
8
5
2
3
1
11
4
5
1
3
8
8
2
3
8
26
10
20
0
1
11
1
11
4
2
1
1
0
1
1
0
2
0
7
5
0
16
0
3
0
0
8
1
10
1
11
62
0
36
0
1...

result:

ok 145 lines

Test #3:

score: 0
Accepted
time: 21ms
memory: 34180kb

input:

317 89607
nbijxrvqztvnbqkgommishjgdqohyakrdfydlvpkuktazejjoyfbijaffzaahjoofyciupjrhbobrwivlizdvfhhvnvpygbjpohwkolowrxcqxfmuohptgkppxvdmhouqevqmfgbfssfjwpdxzinzleyompmzojtkcmvsmkgtbngvxavpnsbyqpwfqhftpfbwsoaeiosobgvdozdrzysucguyokksmrtgaajrmqnuudqigareatptccdorguzwzijjsrsocergjmnmvtarnsegzrutdfixatpp...

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 6ms
memory: 29108kb

input:

24 29
vrlfltoyyzmkfhmfxfnqcjpselwmfxqkksavmdwrtefvphxiyczkfnovtgqcmxvdzhqhumemvinrycarflqxftfeasxydibleflezbeiubghfwghlgtpjdkwtvujxnwzogmxiwzxvznxoehkmhezmvzyibcqqpsxfasovwihnwpijchbnfqnemhgxbutvfjcjwrovrxixbuuqkhpoggshhtfskchwcgyjimcgcqthvhxbezleqalslbczmmkistzwrdrqbngkvioahqxdifaeaqxptnoggguaafdiy...

output:

4
0
1
0
4
2
1
3
2
0
2
1
1
0
3
1
0
1
0
0
0
0
0
2
3
4
2
2
0

result:

ok 29 lines

Test #5:

score: 0
Accepted
time: 8ms
memory: 29084kb

input:

39 31
dtgduerwxqglqmcjjrlyhbufsjnbhshppyvzrkbocdlwpmrogercisrxawpsidsvnsoaozcscfreysoitodshyjvzofogpnrkbrklxeeswejqhyyeosdtilapenigjjurnddlllgnephnftqqbgghkelzpybrumjmmgvxpnlvuiuvhrglvzxktzlhceykjgcuqnlfshntfiqjlgzigbqziqsgodnkdyuhdwekovesixgmjxwxdbjncdfzystbxvxxjakhjdkxrpcfditvdtrnlxuwfjhhruztngmtg...

output:

4
3
0
1
3
1
0
0
0
1
1
0
1
0
1
0
1
0

result:

ok 18 lines

Test #6:

score: 0
Accepted
time: 4ms
memory: 30828kb

input:

36 30
pkmrluwwbyrtdtczxqswqkdpjeymewptoiacwtcbfovwpkcsaixrixyrnofmtiuvfhdiprjewjqdsjjgiiyaoeyexuqngjdardfdwqdhylqkresmakfvuiciudugrdbkrnzuhqceckpvaoeopgsvqcnfutjkwznsmesvuszwepnujkapajpvgxwmjaelarxfgirxbxevifyytnpnmidnguczoshufpnnbpsqhtubdunsdhdireugnozvhcfpnflgicbyxhbcycqqblvsblnknfkpwfokiyqnjrmkcl...

output:

28
0
0
24
0
14
28
1
1
0
0
0
0

result:

ok 13 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 28440kb

input:

2192 2913
hgi
yyumtc
vuwh
vs
bra
asb
nw
ly
mz
gmy
koyeachjhitvauol
suur
xur
mq
pt
jquutracupyvjghj
vu
sf
tziaweh
atssmwvkhdrqhfjbdojkddreecwiiaaevzdtn
jquutracupyvjghb
rs
fh
nl
ldcfo
im
djnh
bexx
krq
jwbxcos
qj
ue
ty
pn
pl
tj
ldcfn
ezkkmadyuru
tb
pu
suud
bext
hb
fk
yyumtl
jquutracupyvjghw
ax
suun
rk...

output:

4

result:

ok single line: '4'

Test #8:

score: 0
Accepted
time: 4ms
memory: 32072kb

input:

3117 3696
hga
jw
puc
uytbqiemzxgywaycp
mr
dptzdkij
fyzr
tbqxo
nsmypi
opwjp
jijesf
ksthei
fa
dptzdkiz
leqy
mtfd
jijest
pzuwdsvbbjuaadlalrzynhwopgtyjwgdaqptzdzlhyicuyudoafjgkpjg
pem
oquq
ym
dptzdkie
rw
nja
leqm
ijhsho
mk
kykr
jijest
dptzdkir
jijesk
mpcpxoibltxhtjuxtjwnpmlszlod
hgq
asnhmyeq
doseewjznqr...

output:

60
10
36
14
1
15
32
30
11
10
417
25
27
7
107
4
26
923
14
2286
3
17
11
42
1
30
15
4
902
4
22
27
24
19
21
4
36
251
4
33
49
27
7
14
44
1
6
5
414
31
8
4
45
7
26
48
7
12
11
8
3
15
3
131
27
14
17
3
18
8
501
25
37
2
9
12
4
16
39
12
26
17
29
31
18
6
8
4
26
4
9
25
0
10
13
139
272
1
1
0
13
4
0
27
24
21
2
32
7...

result:

ok 3696 lines

Test #9:

score: 0
Accepted
time: 82ms
memory: 45316kb

input:

26995 24352
ckzwzs
tyjiyyf
cakgdzwropdgh
ksxmsraek
kastagdvnldl
ltawy
xtx
mbkdllfpayzl
ptjqni
wwwwam
okmgyzj
ipuncesd
h
rzrqrf
pzzpgpvgrbqj
zpfmmrnnmlp
zsahst
sxgvakhw
uxgycidiaw
cyysfcpkif
qszbf
diwhq
ovvlqznfr
tkmiqwlfo
onoyqzarms
pdkw
svn
hayrjpt
pqhxtbeviwnrb
onjvhv
zqjmpxq
dzgef
fjrohigyrrfn
bx...

output:

0
0
0
1
0
0
0
0
39
0
38
0
818
0
0
0
10
0
0
1084
0
0
16416
64
25
1
4213
6
5
0
0
36
0
0
37
0
16
710
0
47
0
0
664
0
0
6051
0
0
18
13
0
0
14
1389
2299
15
8
0
1
0
0
3
20975
0
0
14
62
2
10201
226
56
0
9647
0
0
0
0
0
0
25
25
85
0
0
48
23
13
338
0
33
0
22
0
0
0
5
841
0
0
0
8996
0
332
70
23
21
0
165
16
29
0
...

result:

ok 12191 lines

Test #10:

score: 0
Accepted
time: 105ms
memory: 46512kb

input:

31872 35506
wtchxvefapl
owfr
pkkhyzvnevrm
rovgogz
caoyx
xurv
ajyhrgh
znkn
qvzxbvmd
f
qfqtdbo
ueh
pzj
vrebk
jtmlqfa
glbygmn
btuxctxjmd
ekbqlc
sxyqm
dhdvlx
nubkdnz
zkxmf
drdsxmici
xurvh
d
jtmlqeic
azjoukzmn
cenwtzvpy
qujgckb
rofgzup
ixuacsl
lilwbh
qwyyqbeyufr
fntym
gewbsoshyv
dbuepo
lek
inekxsdnsds
ec...

output:

3
0
9
3
957
127
0
19
159
0
48
137
42
24195
15
4
0
8431
23
35
0
0
0
0
2380
1049
9
0
15
56
0
37
0
0
3
1273
25
35
29
17069
746
26
0
10
156
12
22
3
34
0
39
16206
5
0
0
504
2
66
0
6
5106
1852
0
211
0
42
21
28
27
8
18076
20
14
4
0
0
0
937
0
19
798
0
61
20
2555
12
0
43
0
175
60
5763
133
0
25
0
0
32
14
1
30...

result:

ok 17859 lines

Test #11:

score: 0
Accepted
time: 83ms
memory: 44660kb

input:

23221 25749
wgizrp
kpjngfswox
sujn
drv
crrclnwvuk
gancpmaw
ldsurhxad
yjmriiamkcbngcv
yfjlewa
omfljrl
qv
namskbkmxs
dgxjm
kkbjdcwyghsmbmwp
uk
qvdgaubcqwsalsc
drdjesci
ozncyi
lydrmjz
ahaadhpdgyzw
afgywful
ozncytq
prpdgcnhqukpet
oszbxls
lukllw
ghsdmoplucmq
ucbpiqyxqnzdvb
pxobxw
oxqjjcclzif
huylxcmppxe
...

output:

97
12
56
0
0
0
63
0
22
15
100
44
102
41
0
0
0
0
0
0
33
0
10253
0
38
0
254
2
0
102
123
38
465
471
17
28
501
25
0
0
0
118
10
0
0
0
45
0
91
244
0
84
0
0
2
17
177
79
5859
260
17
84
40
77
0
0
32
123
50
11
7940
708
91
0
179
11
0
14
13
0
0
0
9653
0
18
48
356
20
130
0
0
8884
20
41
23
120
4
50
0
3
15
98
15
7...

result:

ok 12830 lines

Test #12:

score: 0
Accepted
time: 72ms
memory: 43948kb

input:

34761 32323
annaz
rwawgctleg
thxykd
dhcba
jfhvcb
ismifpone
iaryss
hz
nxkpom
sajnqe
ogspgsv
saivzo
oggqv
ismifel
akysnxepy
hntbn
iomjdvkj
gamsx
dqgl
rgfdln
r
gczl
saummz
soo
zrnhurq
gxtc
annazo
s
gotgxf
jzscyfe
ldbih
ensth
ornubs
ywoczhp
e
ziomd
retm
vycnzxfgwp
hqbvgn
jbfol
gvgaxbr
dwkib
annazj
ismif...

output:

0
0
69
38
382
327
139
141
35
1017
26
191
0
0
116
302
0
871
11416
78
80
0
894
0
0
0
0
157
0
0
21270
0
1198
32
0
0
0
222
0
0
392
79
118
195
92
245
13
113
243
1
2309
0
17713
0
174
11477
122
232
17
23
0
160
631
192
16513
12354
0
0
22
224
0
0
543
579
90
8890
0
330
0
190
0
114
391
0
0
0
1357
81
0
989
337
...

result:

ok 8151 lines

Test #13:

score: 0
Accepted
time: 56ms
memory: 42120kb

input:

35597 20949
hrnqq
hq
vyqhsq
a
l
caois
bjbdgtlz
fcfrm
nxhm
qvi
mb
chqbvtj
sqqzo
lonjqysb
mly
tdhakdfp
pijtoxcx
qwjypcl
uvcvoas
dgugxft
xuocrbim
vgs
vbezh
mxamf
sspgtaezu
dtr
twcxa
ycurlheq
c
eembjafcf
lpdkd
wsrkonxor
tta
dtrgw
cpkbku
skky
lanoquy
xshcaczxxn
rgkpwhu
wcbxr
lqiw
reuldnvlrp
bgp
cbbej
hdx...

output:

0
46
0
0
0
0
0
54
0
0
0
0
0
0
0
9
0
0
0
0
0
58
0
0
0
704
0
0
0
9
0
0
0
0
0
0
0
1
0
0
157
0
72
92
64
0
0
12525
1548
923
0
115
0
0
0
0
12
0
1
844
0
0
48
14
82
300
0
0
0
12
0
0
0
14079
0
12
507
0
0
113
0
0
47
2
0
75
0
0
0
0
0
952
0
0
0
55
0
0
0
114
34
0
2
0
8228
0
0
0
0
0
0
0
0
0
0
66
0
0
6
19279
0
0
2...

result:

ok 5180 lines

Test #14:

score: 0
Accepted
time: 43ms
memory: 39292kb

input:

200000 200000
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
b
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
...

output:

99999
199996
99999
2

result:

ok 4 lines

Test #15:

score: 0
Accepted
time: 13ms
memory: 32712kb

input:

2 100000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

2

result:

ok single line: '2'

Test #16:

score: 0
Accepted
time: 844ms
memory: 38772kb

input:

200000 200000
a
a
a
a
a
a
a
a
a
a
a
z
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
b
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
c
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
...

output:

199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996
199996...

result:

ok 199999 lines