提出 #26768646
ソースコード 拡げる
(M,),*UV,P = $<.map{|ln| ln.split.map(&:to_i) }
E = Array.new(10){[]}
UV.each{|u,v|
E[u]<<v
E[v]<<u
}
P << (1..9).find{|c| ! P.index(c) }
n = 0
N = {P=>n}
Q = {P=>P}
n += 1 and Q.keys.each{|s|
Q.delete s
c = s[-1]
E[c].each{|d|
t = s.dup
t[t.index d] = c
t[-1] = d
Q[t],N[t] = t,n unless N[t]
}
} until Q[[*1..9]] || Q.empty?
p(N[[*1..9]]||-1)
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - 8 Puzzle on Graph |
| ユーザ | ds14050 |
| 言語 | Ruby (2.7.1) |
| 得点 | 0 |
| コード長 | 383 Byte |
| 結果 | TLE |
| 実行時間 | 4414 ms |
| メモリ | 113276 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 400 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt, example1.txt, example2.txt, example3.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, example0.txt, example1.txt, example2.txt, example3.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 62 ms | 13972 KiB |
| 001.txt | AC | 61 ms | 14212 KiB |
| 002.txt | AC | 3311 ms | 74312 KiB |
| 003.txt | AC | 418 ms | 24024 KiB |
| 004.txt | AC | 3300 ms | 74068 KiB |
| 005.txt | TLE | 4414 ms | 100536 KiB |
| 006.txt | AC | 63 ms | 14208 KiB |
| 007.txt | AC | 978 ms | 37120 KiB |
| 008.txt | AC | 645 ms | 28444 KiB |
| 009.txt | AC | 986 ms | 37172 KiB |
| 010.txt | AC | 2225 ms | 63952 KiB |
| 011.txt | AC | 62 ms | 14220 KiB |
| 012.txt | AC | 2208 ms | 62104 KiB |
| 013.txt | AC | 2208 ms | 61872 KiB |
| 014.txt | AC | 2208 ms | 61944 KiB |
| 015.txt | AC | 59 ms | 14056 KiB |
| 016.txt | AC | 63 ms | 14060 KiB |
| 017.txt | AC | 63 ms | 14156 KiB |
| 018.txt | AC | 63 ms | 14148 KiB |
| 019.txt | AC | 63 ms | 14376 KiB |
| 020.txt | AC | 64 ms | 14188 KiB |
| 021.txt | AC | 2637 ms | 75740 KiB |
| 022.txt | AC | 763 ms | 33516 KiB |
| 023.txt | AC | 1003 ms | 37376 KiB |
| 024.txt | AC | 3967 ms | 113276 KiB |
| 025.txt | AC | 59 ms | 14136 KiB |
| 026.txt | AC | 61 ms | 14080 KiB |
| 027.txt | AC | 64 ms | 14232 KiB |
| 028.txt | AC | 62 ms | 14240 KiB |
| 029.txt | AC | 64 ms | 14008 KiB |
| 030.txt | AC | 62 ms | 14288 KiB |
| 031.txt | AC | 65 ms | 14344 KiB |
| 032.txt | AC | 2327 ms | 64916 KiB |
| 033.txt | AC | 1287 ms | 42332 KiB |
| 034.txt | AC | 2436 ms | 64484 KiB |
| 035.txt | AC | 1828 ms | 56260 KiB |
| 036.txt | AC | 2011 ms | 58864 KiB |
| 037.txt | AC | 63 ms | 14220 KiB |
| 038.txt | AC | 71 ms | 14320 KiB |
| 039.txt | AC | 67 ms | 14276 KiB |
| 040.txt | AC | 59 ms | 14232 KiB |
| 041.txt | AC | 64 ms | 14176 KiB |
| example0.txt | AC | 59 ms | 14328 KiB |
| example1.txt | AC | 59 ms | 14072 KiB |
| example2.txt | AC | 2216 ms | 62880 KiB |
| example3.txt | AC | 181 ms | 17704 KiB |