Submission #71212471


Source Code Expand

gets.to_i.times{
	r,c = gets.split.map(&:to_i)
	rx = gets.split.map(&:to_i)
	cx = gets.split.map(&:to_i)
	x2i = [nil]*r
	x2j = [nil]*c
	rx.each_with_index{|x,i|
		x2i[x] = i
	}
	cx.each_with_index{|x,j|
		x2j[x] = j
	}
	mtx = Array.new(r){ [nil]*c }

	ix = jx = nil
	(r*c).downto(1){|x|
		i = x2i[x]
		j = x2j[x]
		ix ||= i
		jx ||= j
		if i&&j
			mtx[i][j] = x
		elsif i && jx
			mtx[i][jx] = x
		elsif j && ix
			mtx[ix][j] = x
		end
	}

	que = ([*1..r*c]-mtx.flatten.compact).sort
	ij = [*0...r].product([*0...c]).sort_by{|i,j| [rx[i],cx[j]].min }
	ij.reverse_each{|i,j|
		a = mtx[i][j]
		x = [rx[i],cx[j]].min
		if ! a && que[0] && que[-1]<=x
			mtx[i][j] = que.pop
		end
	}
	if que.empty?
#		warn mtx.flatten.compact.uniq.size==r*c
#		warn mtx.map(&:max)==rx
#		warn mtx.transpose.map(&:max)==cx
		puts 'Yes',mtx.map{|r| r*' ' }
	else
		puts 'No'
	end
}

Submission Info

Submission Time
Task E - Max Matrix 2
User ds14050
Language Ruby 3.4 (ruby 3.4.5)
Score 0
Code Size 906 Byte
Status WA
Exec Time 565 ms
Memory 66264 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 450
Status
AC × 1
AC × 26
WA × 4
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_small_00.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, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_22.txt, 02_random_23.txt, 02_random_24.txt, 02_random_25.txt, 02_random_26.txt, 02_random_27.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 43 ms 15652 KiB
01_small_00.txt AC 269 ms 18428 KiB
02_random_00.txt AC 565 ms 66264 KiB
02_random_01.txt AC 270 ms 50004 KiB
02_random_02.txt AC 296 ms 50580 KiB
02_random_03.txt AC 354 ms 52796 KiB
02_random_04.txt AC 241 ms 49216 KiB
02_random_05.txt AC 216 ms 39228 KiB
02_random_06.txt AC 215 ms 39268 KiB
02_random_07.txt AC 224 ms 39244 KiB
02_random_08.txt AC 224 ms 39256 KiB
02_random_09.txt AC 444 ms 49640 KiB
02_random_10.txt AC 232 ms 38984 KiB
02_random_11.txt AC 283 ms 46296 KiB
02_random_12.txt AC 227 ms 39132 KiB
02_random_13.txt AC 214 ms 19552 KiB
02_random_14.txt AC 210 ms 19532 KiB
02_random_15.txt AC 209 ms 19512 KiB
02_random_16.txt AC 210 ms 19580 KiB
02_random_17.txt WA 203 ms 19592 KiB
02_random_18.txt WA 205 ms 19576 KiB
02_random_19.txt WA 203 ms 19732 KiB
02_random_20.txt WA 202 ms 19552 KiB
02_random_21.txt AC 202 ms 39320 KiB
02_random_22.txt AC 196 ms 39360 KiB
02_random_23.txt AC 167 ms 34560 KiB
02_random_24.txt AC 165 ms 34440 KiB
02_random_25.txt AC 173 ms 34444 KiB
02_random_26.txt AC 173 ms 34452 KiB
02_random_27.txt AC 167 ms 34424 KiB