Submission #38290988


Source Code Expand

(N,M),*E,_,X = $<.map{|ln| ln.split.map(&:to_i) }

G = [-1]*(N+1)
F = lambda{|a|
	G[a]<0 ? a : G[a] = F[G[a]]
}
U = lambda{|a,b|
	a,b = F[a],F[b]
	next if a==b
	a,b = b,a if G[b]<G[a]
	G[a] += G[b]
	G[b] = a
}

E1 = []
E.each.with_index(1){|uv,e|
	if X[0]==e
		X.shift
		E1<<uv
	else
		U[*uv]
	end
}

D = [0]*(N+1)
E1.each{|u,v|
	u,v = F[u],F[v]
	if u!=v
		D[u] += 1
		D[v] += 1
	end
}

puts(2<D.count(&:odd?)?'No':'Yes')

Submission Info

Submission Time
Task G - Unique Walk
User ds14050
Language Ruby (2.7.1)
Score 600
Code Size 456 Byte
Status AC
Exec Time 374 ms
Memory 45488 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 53
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, random2_00.txt, random2_01.txt, random2_02.txt, random2_03.txt, random2_04.txt, random2_05.txt, random2_06.txt, random2_07.txt, random2_08.txt, random2_09.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, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 58 ms 14064 KiB
example_01.txt AC 56 ms 14212 KiB
hand_00.txt AC 370 ms 45488 KiB
hand_01.txt AC 350 ms 34328 KiB
hand_02.txt AC 352 ms 33932 KiB
hand_03.txt AC 361 ms 45488 KiB
hand_04.txt AC 370 ms 45444 KiB
hand_05.txt AC 372 ms 45300 KiB
hand_06.txt AC 372 ms 45224 KiB
hand_07.txt AC 192 ms 27580 KiB
hand_08.txt AC 188 ms 27604 KiB
hand_09.txt AC 189 ms 27752 KiB
hand_10.txt AC 189 ms 27636 KiB
random2_00.txt AC 363 ms 38844 KiB
random2_01.txt AC 372 ms 38868 KiB
random2_02.txt AC 346 ms 41724 KiB
random2_03.txt AC 353 ms 41720 KiB
random2_04.txt AC 360 ms 39664 KiB
random2_05.txt AC 360 ms 39756 KiB
random2_06.txt AC 363 ms 39404 KiB
random2_07.txt AC 369 ms 37284 KiB
random2_08.txt AC 356 ms 41296 KiB
random2_09.txt AC 362 ms 40212 KiB
random_00.txt AC 340 ms 33132 KiB
random_01.txt AC 324 ms 31672 KiB
random_02.txt AC 340 ms 32852 KiB
random_03.txt AC 325 ms 32268 KiB
random_04.txt AC 335 ms 32524 KiB
random_05.txt AC 335 ms 31672 KiB
random_06.txt AC 119 ms 20020 KiB
random_07.txt AC 326 ms 31476 KiB
random_08.txt AC 329 ms 32028 KiB
random_09.txt AC 201 ms 27704 KiB
random_10.txt AC 342 ms 33624 KiB
random_11.txt AC 316 ms 31452 KiB
random_12.txt AC 374 ms 39092 KiB
random_13.txt AC 333 ms 32712 KiB
random_14.txt AC 332 ms 32760 KiB
random_15.txt AC 342 ms 33796 KiB
random_16.txt AC 327 ms 32488 KiB
random_17.txt AC 332 ms 32752 KiB
random_18.txt AC 226 ms 29896 KiB
random_19.txt AC 338 ms 34260 KiB
random_20.txt AC 333 ms 32580 KiB
random_21.txt AC 231 ms 29332 KiB
random_22.txt AC 348 ms 35560 KiB
random_23.txt AC 327 ms 31692 KiB
random_24.txt AC 330 ms 32368 KiB
random_25.txt AC 328 ms 31664 KiB
random_26.txt AC 330 ms 31804 KiB
random_27.txt AC 176 ms 25448 KiB
random_28.txt AC 325 ms 31124 KiB
random_29.txt AC 329 ms 32724 KiB