← Home
For problem statement at 0-999/200-299/260-269/269/problemC.txt this is a correct solution, but verifier at 0-999/200-299/260-269/269/verifierC.go ends with case 1 failed: flow conservation failed at node 2: in=6, out=76
input:
12 17
6 12 78
2 5 34
7 9 44
9 12 80
2 8 42
6 10 90
8 10 46
1 7 72
3 9 24
7 8 100
8 11 34
5 9 28
4 7 42
5 7 58
1 2 6
4 11 44
3 12 34

output:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
exit status 1 can you fix the verifier? ```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

type Edge struct {
	to  int
	cap int
	id  int
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n, m int
	fmt.Fscan(in, &n, &m)

	A := make([]int, m)
	B := make([]int, m)
	C := make([]int, m)
	adj := make([][]Edge, n+1)
	total := make([]int64, n+1)

	for i := 0; i < m; i++ {
		var a, b, c int
		fmt.Fscan(in, &a, &b, &c)
		A[i] = a
		B[i] = b
		C[i] = c
		total[a] += int64(c)
		total[b] += int64(c)
		adj[a] = append(adj[a], Edge{b, c, i})
		adj[b] = append(adj[b], Edge{a, c, i})
	}

	target := make([]int64, n+1)
	target[1] = 0
	target[n] = total[n]
	for i := 2; i < n; i++ {
		target[i] = total[i] / 2
	}

	cur := make([]int64, n+1)
	ans := make([]int, m)
	used := make([]bool, m)

	q := make([]int, 0, n)
	q = append(q, 1)

	for h := 0; h < len(q); h++ {
		u := q[h]
		for _, e := range adj[u] {
			if used[e.id] {
				continue
			}
			used[e.id] = true
			v := e.to
			if A[e.id] == u {
				ans[e.id] = 0
			} else {
				ans[e.id] = 1
			}
			cur[v] += int64(e.cap)
			if cur[v] == target[v] {
				q = append(q, v)
			}
		}
	}

	for i := 0; i < m; i++ {
		fmt.Fprintln(out, ans[i])
	}
}
```