結果
問題 | No.92 逃走経路 |
ユーザー |
|
提出日時 | 2014-12-07 19:37:51 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 787 bytes |
コンパイル時間 | 12,901 ms |
コンパイル使用メモリ | 228,456 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-10 02:36:50 |
合計ジャッジ時間 | 12,592 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
package mainimport ("fmt""strconv""strings")func main() {var n, m, k intfmt.Scan(&n, &m, &k)a := make([]int, m)b := make([]int, m)c := make([]int, m)for i, _ := range a {fmt.Scan(&a[i], &b[i], &c[i])a[i]--b[i]--}ans := make([]bool, n)for i, _ := range ans {ans[i] = true}for i := 0; i < k; i++ {var d intfmt.Scan(&d)next := make([]bool, n)for j, _ := range a {if c[j] != d {continue}if ans[a[j]] {next[b[j]] = true}if ans[b[j]] {next[a[j]] = true}}copy(ans, next)}res := make([]string, 0)for i, v := range ans {if v {res = append(res, strconv.Itoa(i+1))}}fmt.Println(len(res))fmt.Println(strings.Join(res, " "))}