QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#357888#6825. Expenditure Reductioncrsfaa#WA 10ms18140kbC++141.0kb2024-03-19 14:31:052024-03-19 14:31:06

Judging History

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

  • [2024-03-19 14:31:06]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:18140kb
  • [2024-03-19 14:31:05]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
using Yukinoshita Yukino;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
const int mxn=1e5+5;
char s[mxn],s2[mxn],f[mxn];
int nxt[mxn][26+10];
int main()
{
	int T=read();
	while(T--)
	{
		int i,j,mn=1e9,l,r;
		scanf("%s%s",s+1,f+1);
		int n=strlen(s+1),m=strlen(f+1);
		for(i=1;i<=n;i++)
			s2[i]=s[i];
		for(i=1;i<=n;i++)
			s[i]=s[i]>='a'&&s[i]<='z'?s[i]-'a':s[i]-'0'+26;
		for(i=1;i<=m;i++)
			f[i]=f[i]>='a'&&f[i]<='z'?f[i]-'a':f[i]-'0'+26;
		for(i=0;i<26+10;i++)
			nxt[n+1][i]=n+1;
		for(i=n;i;i--)
		{
			memcpy(nxt[i],nxt[i+1],sizeof(nxt[i]));
			if(i<=n)
				nxt[i][s[i+1]]=i+1;
		}
		for(i=1;i<=n;i++)
			if(f[1]==s[i])
			{
				int w=i;
				for(j=2;j<=m;j++)
					w=nxt[w][f[j]];
				if(w<=n) mn=min(mn,w-i+1),l=i,r=w;
			}
		for(;l<=r;l++)
			putchar(s2[l]);
		puts("");
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

4
114514 15
shanghaicpc ac
aaabbbaaabbbccc abc
howdeliciousandfreshitis oishii

output:

145
aic
abbbc
owdeliciousandfreshiti

result:

ok T=4 (4 test cases)

Test #2:

score: 0
Accepted
time: 9ms
memory: 3656kb

input:

10000
9fk811aek6newrfy7hvdsln282g1dcpa829bum5x1lpfdq9qd6 9f8ek6newyvdn282ca29b5x1ld9q
vg36oa5ncf4spe59gyplp1mi1or1hji2q0lcpubvxglbjjdyjm 365f4spe59glpm1oh2qpuvxjm
h604exipq7eg5gvy1n06mugqlxqyqd5kao0u12rsrfs2m4lpez h60e70muglxyd5k0u1le
33kmdcvnzvmkyjylt2kvck8fiy32jabu0rcnbhogqrnfi3hj6j 3mdcnzkyjlvk8f...

output:

9fk811aek6newrfy7hvdsln282g1dcpa829bum5x1lpfdq9q
36oa5ncf4spe59gyplp1mi1or1hji2q0lcpubvxglbjjdyjm
h604exipq7eg5gvy1n06mugqlxqyqd5kao0u12rsrfs2m4lpe
3kmdcvnzvmkyjylt2kvck8fiy32jabu0rcnbhogqrnfi3hj6
2f2ukqz1k3vbbs1x9o746i69vw675te94myxgqf0hesz0d6x4
12eqrshrg591ze2wjqpdcplm7ugkb9fo8v0xyk4r5ts4ikz86
akz...

result:

ok T=10000 (10000 test cases)

Test #3:

score: 0
Accepted
time: 9ms
memory: 3564kb

input:

10000
6cysrabtpdhyfa680e7we7y2iyzszuknxcecsiumsumvpafaia thyfa8e7yzsknxccmmvafaa
rq6siapzyeqi5lzp7ilxyrdps65lsqcsg8mggea0imxu7yenjs rqiazy5lp7lypcs8gge0ixyens
9u6kjiebgugm7sw7bbs172rh5z5s3vrghq81yy2q5pnh5oem5w 6kieusw7bbs7rz53vg1yqpnh5e5
ggjmpuw3a23s3pjhuh3v7x6nw9b573r6jxpoaz9txh11hc9ikz gjm23s3pu36...

output:

tpdhyfa680e7we7y2iyzszuknxcecsiumsumvpafaia
rq6siapzyeqi5lzp7ilxyrdps65lsqcsg8mggea0imxu7yenjs
6kjiebgugm7sw7bbs172rh5z5s3vrghq81yy2q5pnh5oem5
gjmpuw3a23s3pjhuh3v7x6nw9b573r6jxpoaz9txh11hc9ik
cerj5uygs85eklvmpjoihdrwlemdkantywth7lvlvbj9mscu9
goe9iw7n8xu52ywzi4dy1umik9f30wa7hn8wye3nb3jj2c
co2vv5xffek...

result:

ok T=10000 (10000 test cases)

Test #4:

score: 0
Accepted
time: 9ms
memory: 5852kb

input:

10000
svla166dvrllf9ze28r00vhp38maebj7l0r9wraw9q4bn0wu5b va66drll280vhp8ae7l09r4bu5
4cg2youkigm85sgxmd4ebg1bjeuv8klks8h4c7p0prasz2ucmk 4c2yokid4b1juvs4c0raz2um
54lpldj9yg0dl6yj3z821qzdfwqegrtr6a66wph0cxgezh8qkw 5l9yd6yj1zfwrr66cxgez8qw
1rlxhnkocrpz7yym42nrvdvyn458ioy7wivdhhxyvr5q56ib3t rxhkocyym4rvd...

output:

vla166dvrllf9ze28r00vhp38maebj7l0r9wraw9q4bn0wu5
4cg2youkigm85sgxmd4ebg1bjeuv8klks8h4c7p0prasz2ucm
54lpldj9yg0dl6yj3z821qzdfwqegrtr6a66wph0cxgezh8qkw
rlxhnkocrpz7yym42nrvdvyn458ioy7wivdhhxyvr5q56ib
gdew5j34ja8iddldwrvzgpayaf0bwj9noby27tglxci0uq4ed
61fr8e7hxmtrszb7tmqgvskg6bn68azbjpuj9bycsoe8jjzuix
s...

result:

ok T=10000 (10000 test cases)

Test #5:

score: 0
Accepted
time: 9ms
memory: 3832kb

input:

10000
fv2mwmg9hmqrmwwtmoohy44w4hct7f7vqgm6gqxzg1f6m41knn wg9mrmmhy4c7qmgz641kn
iqx3ry9cplusrblrx0x50tzgxxoorfxhmzb2b3tx9dptwujyiv q3csrbx5tzgf2btdtwyiv
24s5jwn9bswkac5c18i3xbki8b60h56w77f4ur2o42ornbk8iq 2s5jbsa3bb60hw7f4r42ornk8i
sre8m6anb8wgkhdbncj211d60vpf2wfqsob4mjmds7doqwslaf mnwgkhbncj110vp2qob...

output:

wmg9hmqrmwwtmoohy44w4hct7f7vqgm6gqxzg1f6m41kn
qx3ry9cplusrblrx0x50tzgxxoorfxhmzb2b3tx9dptwujyiv
24s5jwn9bswkac5c18i3xbki8b60h56w77f4ur2o42ornbk8i
m6anb8wgkhdbncj211d60vpf2wfqsob4mjmds7doqwslaf
qj7e0yxrut3s8ahbi4bwjrk1kdaezbe0j8wvvt4i2or0mp
jx6gjajme9l995wjvdld5tzo0wbwqsduob4wg9pwvgjub6pqb
vz1xhkdpwf...

result:

ok T=10000 (10000 test cases)

Test #6:

score: 0
Accepted
time: 9ms
memory: 5700kb

input:

10000
81dlg0rmlp9a2l31r4uk2f6d853fc8t39sejyioagsh0us7ew7 mp92ruk2f6d83fc39jigshuew
3861lu9p95ljn5qpk942tjitzepd0gzdjsdgu0msljrman9211 6u95ln5qp94tized0zjsduslra1
r8gmbt2g8swb8w83pfzw6hncq7akoh4swn2fmpg28jakkyh9g9 r8bgs8w83pfzw6ck4s2mp2aky9g9
eymebzo1z1icb0phl3af9m7zi1pf9cd1n9qvd4ugtl8fxnstn1 eymzo1z...

output:

mlp9a2l31r4uk2f6d853fc8t39sejyioagsh0us7ew
61lu9p95ljn5qpk942tjitzepd0gzdjsdgu0msljrman921
r8gmbt2g8swb8w83pfzw6hncq7akoh4swn2fmpg28jakkyh9g9
eymebzo1z1icb0phl3af9m7zi1pf9cd1n9qvd4ugtl8fxnst
j7pvu828hq16o69ixnshvy34aykon2qeqfhjyx8odazekvrz9n
b4qrjct4ywk1ag9klvli5dlajmpszjpy3sby18uglsrrlc86qd
xcdgkrj...

result:

ok T=10000 (10000 test cases)

Test #7:

score: 0
Accepted
time: 9ms
memory: 3840kb

input:

10000
btz0nhud6lz2nd7t7urspfqaso32w0lo71cux6eq6k8pswc0dx zhuz2d7trfas320l716q6kscd
t4h2gigi5201u4b34ivmixdigtne7k13vzklf04akxuuq76k7k t42gig52143vtnk1vzk04kqk
bu7nwwtd9o035tjzsm0kf8243bh4m2s8j5cds7v19wwwa8m78k u7wwt9o35tjzsmk23mjds9k
85p2obgf0tnacu251i6axptekaq2njjuwuknmr4xkiep3kso3a p2nac16aptek2jj...

output:

z0nhud6lz2nd7t7urspfqaso32w0lo71cux6eq6k8pswc0d
t4h2gigi5201u4b34ivmixdigtne7k13vzklf04akxuuq76k
u7nwwtd9o035tjzsm0kf8243bh4m2s8j5cds7v19wwwa8m78k
p2obgf0tnacu251i6axptekaq2njjuwuknmr4xkiep3kso3a
8hzmvrhblm09rmbixno48i3ost2c4yysvp74ep1c6po6ciybev
yjeruif6xanypl9nekkrrbgeqd6gtoz3mzls0rp31y1oq7u0f
b77...

result:

ok T=10000 (10000 test cases)

Test #8:

score: 0
Accepted
time: 9ms
memory: 3836kb

input:

10000
v1e3mt9il34t4wc3hmaae3u8p32vxzcp4yl76fruo5k4bnpali ve3t9l3t4cmaae83vzcpfuo5al
vker5kk4iffrke60k1p47j04rthhurr8n2pwwe85wjknoculqy ker5kifre6p7jrhnpwwjknuy
czrw3ayajdofgbkd8tto919ov8g93iq015r27696os0xjutnk5 waadgbkd8tto9199i1r276osxjn5
4zxg00fpbgjwr2zxrp42q0ecrc6ng1f3fuqdp0bz1roqsnxc79 zxg0fgj2r...

output:

v1e3mt9il34t4wc3hmaae3u8p32vxzcp4yl76fruo5k4bnpal
ker5kk4iffrke60k1p47j04rthhurr8n2pwwe85wjknoculqy
w3ayajdofgbkd8tto919ov8g93iq015r27696os0xjutnk5
zxg00fpbgjwr2zxrp42q0ecrc6ng1f3fuqdp0bz1roqsnxc
yijtcj7mtcbrtq2stidvtab9482j5car3ubhzu4efu3pvl
sugmncs8pek99gdivqze4vwofnjpjdaakkethdgkh9sqnh9
1kzd5ksxk...

result:

ok T=10000 (10000 test cases)

Test #9:

score: 0
Accepted
time: 9ms
memory: 3648kb

input:

10000
b6zb0tqa6l4ghc5smhnz173f7tuj017tj11ntj9d1ikn26tsid zql4csmhn13f01jd1k2ti
be6ce19orr3iqn0nbd1002kruwbbmvnsyu18tstt5cebg3hvul b6iqn002kruwbbmutebghv
hnxb53lm4jo4ed0qulke4d5oyg2zs4tot698kl9nnsa13g7qej hb53lm4edqul4d5oyzs4tokl9n1qj
bat0tusriw6ei3dnzsmopysqr9sfmaw6poywj8gw62q0jkhpgx aw6i3nsmpqr9smw...

output:

zb0tqa6l4ghc5smhnz173f7tuj017tj11ntj9d1ikn26tsi
be6ce19orr3iqn0nbd1002kruwbbmvnsyu18tstt5cebg3hv
hnxb53lm4jo4ed0qulke4d5oyg2zs4tot698kl9nnsa13g7qej
at0tusriw6ei3dnzsmopysqr9sfmaw6poywj8gw62q0jkhpgx
bvtexqm4mnkhf3r71pszdjzixgh48w0w414v1wfjl4
pndgjf0pxob3ooofypk1kejm9f4siiqf0f2b0a3pwj3l4ep
z4whk85yn91...

result:

ok T=10000 (10000 test cases)

Test #10:

score: 0
Accepted
time: 5ms
memory: 3740kb

input:

10000
hv0le8qb6yl9154rtuy15lgmik17i130r7a32f0fz6k00v0lad v0leqlrtulmk71302f0fza
ngffpf1uqkw1bajzlf30zk3089s7owka7vbth4dqj84odm5we7 fp1qbaz309s7owkvbth4qj84odm5e7
ke33ah582jutnvdd4bem4esq177kuieec72qwg61n8235gt17s k3h58udmes17kc2wg6n835gt1s
ryg4nds8q1p611ntw7vhe5oghppout2q4dm6r8pal7esrg81x0 ynsq161tw...

output:

v0le8qb6yl9154rtuy15lgmik17i130r7a32f0fz6k00v0la
fpf1uqkw1bajzlf30zk3089s7owka7vbth4dqj84odm5we7
ke33ah582jutnvdd4bem4esq177kuieec72qwg61n8235gt17s
yg4nds8q1p611ntw7vhe5oghppout2q4dm6r8pal7esrg81x0
t8etwcgg51ujdp1qr3lf5a6mhj883vnqf3iszvb4mx461f3l
4vhx9hwnm2id332ecph1o8994wfpf2j5xaoki4fhb0glsph5d
oej...

result:

ok T=10000 (10000 test cases)

Test #11:

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

input:

10000
mvjr9wrjjuidw84p0o0mmi9khovk24f8om0vbvpe9i8efr2h50 mwjji40omhok480bpif2h50
57pnyfekpxw1mqwd6bvu9tssyrqxgbr3y2myl2o0ceiwrx8014 5pnyfkmw69syrqr3y2yl0cer801
bboqu5tg08yn0idu5fxhao8qmlqunhz752snuy5ndb1wf85cvo bboqugy0i5fxhqhz72ndb1f8o
rc8yreps56y3tdynea756plcqc0njh8y8frnfg5rxqu8p1jmkh rcrs5yne76lc...

output:

mvjr9wrjjuidw84p0o0mmi9khovk24f8om0vbvpe9i8efr2h50
57pnyfekpxw1mqwd6bvu9tssyrqxgbr3y2myl2o0ceiwrx801
bboqu5tg08yn0idu5fxhao8qmlqunhz752snuy5ndb1wf85cvo
rc8yreps56y3tdynea756plcqc0njh8y8frnfg5rxqu8p1jmkh
g07g36dm1t7klkumyb729xm7uv5pn36ee4dz9k05xyp59ck
ebc8gurlppi85luptlg0h0no3q5k8kvbl5bivfp6ur38jib3
...

result:

ok T=10000 (10000 test cases)

Test #12:

score: -100
Wrong Answer
time: 10ms
memory: 18140kb

input:

5
qypxgjbizdkyhvw7qp90lcd4eezlqobnqsvp5y0titdnovtjxfh4n9pig5rm0dt5k86daey4a8q4nid0jcs3j4k294fgywoa4ucm8mt8zjuqwzmzqrluelnc4bb2mf1g77riftb96i2hxu5nl2tv7nwnsj65qpvfugm9lkm0glwolsw4milch4nmm5dv11bj46e6ekrpmqgwqondwqqec0x71gnkf05jzml87vbqj23paosppeuq9q5ggxu5gwc45vj2lj1hfzzlzjncarv92purs4bwd4sgl9hwcn9n8m...

output:

yl2nnjbvin4aaiuf2sppp2sq75lrfkyukd3kevth0au0lesplpsldhjxh7z3jcoztieq2czrt2q7wlqx54fuu3640cobiueygo4qdmonohf4tiiuu2o8y7xhq6avwsfit8zf83evbnfbmbk6xi3dkz0tldct3u2ccf2vpyvs34xvvu1bt22yhxebjvws1na5qy25pknnw0jpq32nbgl7mjuwdsqssj9dpihh9cmb0smnqx6ty21z81yaa0pajfhkwv7x4e7z3pryjqwa387fj31ojob48v7zdss2czh2bkif...

result:

wrong answer Jury has a shorter answer (test case 1)