Exemple #1
0
func main() {
	var s, t, m, q int

	fmt.Scanf("%d", &n)
	fmt.Scanf("%d", &m)

	for i := 0; i < n; i++ {
		G[i] = lib.NewVector(MAX)
	}
	for i := 0; i < m; i++ {
		fmt.Scanf("%d", &s)
		fmt.Scanf("%d", &t)
		vs := G[s]
		vs.PushBack(t)
		vt := G[t]
		vt.PushBack(s)
	}

	fmt.Println(G)

	assignColor()

	fmt.Scanf("%d", &q)

	fmt.Println(color)
	for i := 0; i < q; i++ {
		fmt.Scanf("%d", &s)
		fmt.Scanf("%d", &t)
		if color[s] == color[t] {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}
Exemple #2
0
func main() {
	var x, y int

	fmt.Scanf("%d", &N)
	P = make(Ps, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d", &x, &y)
		P[i] = NewPoint(i, x, y)
		T[i].l = NIL
		T[i].r = NIL
		T[i].p = NIL
	}
	np = 0
	root := makeKDTree(0, N, 0)

	log.Println(P)
	log.Println(T)
	var q int
	fmt.Scanf("%d", &q)
	var sx, tx, sy, ty int
	for i := 0; i < q; i++ {
		fmt.Scanf("%d %d %d %d", &sx, &tx, &sy, &ty)
		ans := lib.NewVector(N)
		log.Println(ans)
		find(root, sx, tx, sy, ty, 0, ans)
		for j := 0; j < ans.Size(); j++ {
			an := ans.V[j]
			ap := an.(Point)
			ap.disp()
		}
	}
}