N = int(input())
g = [[] for _ in range(N)]
for i in range(N - 1):
u, v = map(int, input().split())
g[u - 1].append(v - 1)
colors = is_bipartite(g)[1]
left = colors.count(0)
right = N - left
print(left * right - N + 1)
# print(colors)
And I got WA on test 3 :(
The input data is:
10
3 8
6 2
9 7
10 1
3 5
1 3
6 7
5 4
3 6
and the colors in my program is
[0, 1, 1, 1, 0, 0, 1, 0, 0, 0]
Expected
[0, 1, 1, 1, 0, 0, 1, 0, 0, 1]
Additional context
It seen the bug will be happend if there are edge start from the last point.
like:
3
1 2
3 2
Maybe my code or usage was wrong. idk
I'm a cf specialist from Taiwan.
Sorry to bother.
Python Version: 3.7
Describe the bug I was using is_bipartite() on https://codeforces.com/contest/862/problem/B this is my code (omit def is_bipartite):
And I got WA on test 3 :(
The input data is:
and the colors in my program is
Expected
Additional context It seen the bug will be happend if there are edge start from the last point. like:
Maybe my code or usage was wrong. idk I'm a cf specialist from Taiwan. Sorry to bother.