結果
問題 | No.1190 Points |
ユーザー | 👑 箱星 |
提出日時 | 2020-08-22 14:42:36 |
言語 | Kotlin (1.9.23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,004 bytes |
コンパイル時間 | 15,919 ms |
コンパイル使用メモリ | 459,624 KB |
実行使用メモリ | 164,364 KB |
最終ジャッジ日時 | 2024-04-23 09:01:39 |
合計ジャッジ時間 | 26,510 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 310 ms
60,308 KB |
testcase_01 | AC | 288 ms
92,308 KB |
testcase_02 | AC | 320 ms
64,044 KB |
testcase_03 | AC | 930 ms
103,412 KB |
testcase_04 | AC | 879 ms
103,228 KB |
testcase_05 | AC | 883 ms
104,140 KB |
testcase_06 | AC | 1,006 ms
117,076 KB |
testcase_07 | AC | 1,050 ms
118,772 KB |
testcase_08 | TLE | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
コンパイルメッセージ
Main.kt:24:23: warning: name shadowed: p val (v, step, p) = que.poll() ^ Main.kt:39:23: warning: name shadowed: p val (v, step, p) = que.poll() ^
ソースコード
import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import java.io.PrintWriter import java.util.* fun PrintWriter.solve(sc: FastScanner) { val n = sc.nextInt() val m = sc.nextInt() val p = sc.nextInt() val s = sc.nextInt() - 1 val g = sc.nextInt() - 1 val adj = Array(n) { mutableSetOf<Int>() } for (i in 0 until m) { val v1 = sc.nextInt() - 1 val v2 = sc.nextInt() - 1 adj[v1].add(v2) adj[v2].add(v1) } val dist = IntArray(n) { 0 } val que: Queue<Triple<Int, Int, Int>> = ArrayDeque() que.add(Triple(s, 0, -1)) while (que.count() > 0) { val (v, step, p) = que.poll() dist[v] = step for (w in adj[v]) { if (w == p) continue que.add(Triple(w, step + 1, v)) } } if (p % 2 != dist[g] % 2 || dist[g] > p) { println(-1) return } val dist2 = IntArray(n) { 0 } que.clear() que.add(Triple(g, 0, -1)) while (que.count() > 0) { val (v, step, p) = que.poll() dist2[v] = step for (w in adj[v]) { if (w == p) continue que.add(Triple(w, step + 1, v)) } } val lst = mutableListOf<Int>() for (i in 0 until n) { if (dist[i] + dist2[i] <= p) { lst.add(i + 1) } } println(lst.count()) println(lst.joinToString("\n")) } fun main() { val writer = PrintWriter(System.out, false) writer.solve(FastScanner(System.`in`)) writer.flush() } class FastScanner(s: InputStream) { private var st = StringTokenizer("") private val br = BufferedReader(InputStreamReader(s)) fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() fun ready() = br.ready() }