結果

問題 No.92 逃走経路
ユーザー ichyoichyo
提出日時 2014-12-07 19:37:51
言語 Go
(1.22.1)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 787 bytes
コンパイル時間 12,197 ms
コンパイル使用メモリ 227,324 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 09:20:29
合計ジャッジ時間 11,740 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 13 ms
5,376 KB
testcase_06 AC 15 ms
5,376 KB
testcase_07 AC 15 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 13 ms
5,376 KB
testcase_11 AC 15 ms
5,376 KB
testcase_12 AC 17 ms
5,376 KB
testcase_13 AC 11 ms
5,376 KB
testcase_14 AC 15 ms
5,376 KB
testcase_15 AC 19 ms
5,376 KB
testcase_16 AC 23 ms
5,376 KB
testcase_17 AC 30 ms
5,376 KB
testcase_18 AC 30 ms
5,376 KB
testcase_19 AC 30 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n, m, k int
	fmt.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 int
		fmt.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, " "))
}
0