結果

問題 No.1477 Lamps on Graph
ユーザー yuruhiyayuruhiya
提出日時 2021-04-17 15:55:16
言語 Crystal
(1.11.2)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 19,991 ms
コンパイル使用メモリ 258,984 KB
実行使用メモリ 24,248 KB
最終ジャッジ日時 2023-09-17 01:12:35
合計ジャッジ時間 26,158 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 3 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,468 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,484 KB
testcase_06 AC 3 ms
4,388 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 2 ms
4,484 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 65 ms
10,916 KB
testcase_13 AC 58 ms
11,756 KB
testcase_14 AC 79 ms
11,700 KB
testcase_15 AC 38 ms
7,128 KB
testcase_16 AC 23 ms
8,692 KB
testcase_17 AC 21 ms
8,540 KB
testcase_18 AC 55 ms
15,148 KB
testcase_19 AC 51 ms
11,628 KB
testcase_20 AC 23 ms
6,928 KB
testcase_21 AC 46 ms
14,184 KB
testcase_22 AC 17 ms
5,640 KB
testcase_23 AC 49 ms
7,736 KB
testcase_24 AC 89 ms
14,168 KB
testcase_25 AC 33 ms
7,392 KB
testcase_26 AC 73 ms
15,236 KB
testcase_27 AC 44 ms
8,068 KB
testcase_28 AC 50 ms
10,204 KB
testcase_29 AC 48 ms
9,324 KB
testcase_30 AC 28 ms
9,964 KB
testcase_31 AC 24 ms
9,440 KB
testcase_32 AC 109 ms
24,248 KB
testcase_33 AC 97 ms
19,352 KB
testcase_34 AC 77 ms
20,648 KB
testcase_35 AC 109 ms
18,468 KB
testcase_36 AC 115 ms
18,488 KB
testcase_37 AC 100 ms
17,116 KB
testcase_38 AC 100 ms
17,204 KB
testcase_39 AC 109 ms
18,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def r;read_line.split.map &.to_i;end
n,m=r
a=r
g=a.map{[]of Int32}
m.times{
	u,v=r.map &.pred
	g[v]<<u if a[u]>a[v]
	g[u]<<v if a[v]>a[u]
}
r
f=[0]*n
r.each{|i|f[i-1]=1}

ans=(0...n).to_a.sort_by{|i|a[i]}.select{|i|
	if f[i]>0
		f[i]=0
		g[i].map{|j|f[j]^=1}
	end
}
if f.all? 0
	puts ans.size,ans.join '\n',&.succ
else
	p -1
end
0