Submission #55827067


Source Code Expand

N,K = gets.split.map(&:to_i)
S = gets.chomp.bytes.then{|s|
	u = s.uniq
	next s.map{|b| u.index b }
}
T = Hash.new 0
F = lambda{|ts,ss|
	if ss.empty?
		T[ts.inject(0){|a,c| a*10+c }] += 1 if (N-K+1).times.none?{|i|
			(K/2).times.all?{|j|
				ts[i+j]==ts[i+K+~j]
			}
		}
	else
		ss.uniq.each{|c|
			ts.push ss.delete_at ss.index c
			F[ts,ss]
			ss.push ts.pop
		}
	end
}
F[[],S]
p T.size

Submission Info

Submission Time
Task C - Avoid K Palindrome 2
User ds14050
Language Ruby (ruby 3.2.2)
Score 0
Code Size 412 Byte
Status TLE
Exec Time 2210 ms
Memory 54652 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
TLE × 1
AC × 33
TLE × 5
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt
Case Name Status Exec Time Memory
example_00.txt AC 102 ms 17220 KiB
example_01.txt AC 49 ms 17448 KiB
example_02.txt TLE 2209 ms 36220 KiB
hand_00.txt AC 48 ms 17140 KiB
hand_01.txt AC 46 ms 17276 KiB
hand_02.txt TLE 2209 ms 36172 KiB
hand_03.txt TLE 2210 ms 54652 KiB
hand_04.txt AC 46 ms 17252 KiB
hand_05.txt AC 514 ms 19976 KiB
hand_06.txt AC 516 ms 19928 KiB
random_00.txt AC 46 ms 17152 KiB
random_01.txt AC 46 ms 17152 KiB
random_02.txt AC 46 ms 17548 KiB
random_03.txt AC 46 ms 17420 KiB
random_04.txt AC 45 ms 17216 KiB
random_05.txt AC 48 ms 17396 KiB
random_06.txt AC 54 ms 17436 KiB
random_07.txt AC 50 ms 17460 KiB
random_08.txt AC 53 ms 17464 KiB
random_09.txt AC 74 ms 17752 KiB
random_10.txt AC 54 ms 17408 KiB
random_11.txt AC 1137 ms 22392 KiB
random_12.txt AC 166 ms 18008 KiB
random_13.txt AC 167 ms 18000 KiB
random_14.txt TLE 2209 ms 36356 KiB
random_15.txt AC 452 ms 19980 KiB
random_16.txt AC 1331 ms 22328 KiB
random_17.txt TLE 2209 ms 36368 KiB
random_18.txt AC 45 ms 17180 KiB
random_19.txt AC 45 ms 17128 KiB
random_20.txt AC 47 ms 17492 KiB
random_21.txt AC 46 ms 17476 KiB
random_22.txt AC 52 ms 17592 KiB
random_23.txt AC 61 ms 17504 KiB
random_24.txt AC 56 ms 17456 KiB
random_25.txt AC 56 ms 17492 KiB
random_26.txt AC 511 ms 19944 KiB
random_27.txt AC 518 ms 19792 KiB