Submission #47752502


Source Code Expand

N,M = gets.split.map(&:to_i)
S = gets
T = gets.chomp
Fill = lambda{|l,r|
	(l...r).each{|i| S[i] = ?_ }
	next l,r
}
Ext = lambda{|l,r;z|
	l = Fill[l-z,l][0] while z = M.downto(1).find{|z| S[l-z,z]==T[0,z] }
	r = Fill[r,r+z][1] while z = M.downto(1).find{|z| S[r,z]==T[-z,z] }
	next l,r
}

i = 0
i = Ext[*Fill[i,i+M]][1] while i = S.index(T,i)
pfx = S[0,S.index(?_)||N]
sfx = S[(S.rindex(?_)||-1)+1...N]

puts(T.start_with?(pfx)&&T.end_with?(sfx)&&S.chomp.split(/_+/).all?{|w| T[w] } ? 'Yes':'No')

Submission Info

Submission Time
Task E - Stamp
User ds14050
Language Ruby (ruby 3.2.2)
Score 475
Code Size 515 Byte
Status AC
Exec Time 393 ms
Memory 31192 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 51
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 02_random2y_00.txt, 02_random2y_01.txt, 02_random2y_02.txt, 02_random2y_03.txt, 02_random2y_04.txt, 02_random2y_05.txt, 02_random2y_06.txt, 02_random2y_07.txt, 02_random2y_08.txt, 02_random2y_09.txt, 02_random2y_10.txt, 02_random2y_11.txt, 02_random2y_12.txt, 02_random2y_13.txt, 02_random2y_14.txt, 02_random2y_15.txt, 03_random2n_00.txt, 03_random2n_01.txt, 03_random2n_02.txt, 03_random2n_03.txt, 03_random2n_04.txt, 03_random2n_05.txt, 03_random2n_06.txt, 03_random2n_07.txt, 03_random2n_08.txt, 03_random2n_09.txt, 03_random2n_10.txt, 03_random2n_11.txt, 03_random2n_12.txt, 03_random2n_13.txt, 03_random2n_14.txt, 03_random2n_15.txt, 04_killer_00.txt, 04_killer_01.txt, 04_killer_02.txt, 04_killer_03.txt, 05_handmade_00.txt, 05_handmade_01.txt, 05_handmade_02.txt, 05_handmade_03.txt, 05_handmade_04.txt, 05_handmade_05.txt, 05_handmade_06.txt, 05_handmade_07.txt, 05_handmade_08.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 131 ms 17060 KiB
00_sample_01.txt AC 45 ms 17236 KiB
00_sample_02.txt AC 45 ms 17160 KiB
01_random_00.txt AC 45 ms 17508 KiB
01_random_01.txt AC 45 ms 17416 KiB
01_random_02.txt AC 46 ms 17276 KiB
02_random2y_00.txt AC 140 ms 22488 KiB
02_random2y_01.txt AC 230 ms 27432 KiB
02_random2y_02.txt AC 55 ms 17856 KiB
02_random2y_03.txt AC 228 ms 27292 KiB
02_random2y_04.txt AC 197 ms 18260 KiB
02_random2y_05.txt AC 207 ms 18436 KiB
02_random2y_06.txt AC 160 ms 24852 KiB
02_random2y_07.txt AC 208 ms 27608 KiB
02_random2y_08.txt AC 157 ms 18356 KiB
02_random2y_09.txt AC 186 ms 18744 KiB
02_random2y_10.txt AC 55 ms 17512 KiB
02_random2y_11.txt AC 188 ms 18176 KiB
02_random2y_12.txt AC 89 ms 17676 KiB
02_random2y_13.txt AC 175 ms 18692 KiB
02_random2y_14.txt AC 105 ms 22148 KiB
02_random2y_15.txt AC 182 ms 26916 KiB
03_random2n_00.txt AC 159 ms 17624 KiB
03_random2n_01.txt AC 221 ms 17644 KiB
03_random2n_02.txt AC 62 ms 17432 KiB
03_random2n_03.txt AC 228 ms 17672 KiB
03_random2n_04.txt AC 183 ms 18256 KiB
03_random2n_05.txt AC 205 ms 18404 KiB
03_random2n_06.txt AC 122 ms 23372 KiB
03_random2n_07.txt AC 196 ms 17656 KiB
03_random2n_08.txt AC 174 ms 18444 KiB
03_random2n_09.txt AC 184 ms 18516 KiB
03_random2n_10.txt AC 167 ms 31192 KiB
03_random2n_11.txt AC 159 ms 18340 KiB
03_random2n_12.txt AC 88 ms 17484 KiB
03_random2n_13.txt AC 178 ms 18704 KiB
03_random2n_14.txt AC 107 ms 17756 KiB
03_random2n_15.txt AC 173 ms 17568 KiB
04_killer_00.txt AC 393 ms 27188 KiB
04_killer_01.txt AC 391 ms 27220 KiB
04_killer_02.txt AC 386 ms 17708 KiB
04_killer_03.txt AC 383 ms 27180 KiB
05_handmade_00.txt AC 45 ms 17200 KiB
05_handmade_01.txt AC 46 ms 17172 KiB
05_handmade_02.txt AC 248 ms 27392 KiB
05_handmade_03.txt AC 249 ms 28648 KiB
05_handmade_04.txt AC 110 ms 27220 KiB
05_handmade_05.txt AC 45 ms 17228 KiB
05_handmade_06.txt AC 45 ms 17296 KiB
05_handmade_07.txt AC 45 ms 17116 KiB
05_handmade_08.txt AC 45 ms 17072 KiB