Submission #69089475


Source Code Expand

N = gets.to_i
ST = N.times.map{ gets.split.map(&:to_i) }
(S,IS),(T,IT) = ST.transpose.map{|ss| [ss,N.times.sort_by{|i| ss[i] }] }
if IS!=IT
	puts 'No'
	exit
end
# IS==IT

A = []
Aed = [false]*N
F = lambda{|k|
	i,j = IJ[k]
	s,t = S[i],T[i]
	next true if Aed[k]

	if j && S[j]<t
		F[k+1]
	end
	if ! j || t<S[j]
		S[i] = t
		A<<i+1
		Aed[k] = true
	end

	next Aed[k]
}
IJ = *[*IS,nil].each_cons(2)
if N.times.all?(&F)
	puts 'Yes',A*' '
else
	puts 'No'
end

Submission Info

Submission Time
Task C - No Collision Moves
User ds14050
Language Ruby (ruby 3.2.2)
Score 600
Code Size 486 Byte
Status AC
Exec Time 550 ms
Memory 167564 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 27
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_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 127 ms 16984 KiB
00_sample_01.txt AC 47 ms 17224 KiB
00_sample_02.txt AC 46 ms 17168 KiB
01_handmade_00.txt AC 46 ms 17020 KiB
01_handmade_01.txt AC 46 ms 17180 KiB
01_handmade_02.txt AC 550 ms 167564 KiB
01_handmade_03.txt AC 477 ms 59508 KiB
01_handmade_04.txt AC 487 ms 61024 KiB
01_handmade_05.txt AC 347 ms 45852 KiB
01_handmade_06.txt AC 518 ms 116352 KiB
01_handmade_07.txt AC 491 ms 89464 KiB
02_random_00.txt AC 317 ms 40924 KiB
02_random_01.txt AC 83 ms 20072 KiB
02_random_02.txt AC 157 ms 28324 KiB
02_random_03.txt AC 348 ms 46044 KiB
02_random_04.txt AC 358 ms 45248 KiB
02_random_05.txt AC 340 ms 43156 KiB
02_random_06.txt AC 340 ms 42496 KiB
02_random_07.txt AC 351 ms 44768 KiB
02_random_08.txt AC 148 ms 29232 KiB
02_random_09.txt AC 109 ms 30724 KiB
02_random_10.txt AC 432 ms 93876 KiB
02_random_11.txt AC 290 ms 49024 KiB
02_random_12.txt AC 490 ms 92296 KiB
02_random_13.txt AC 489 ms 84224 KiB
02_random_14.txt AC 480 ms 85648 KiB
02_random_15.txt AC 464 ms 69552 KiB