#P8250. Photo Sharing Without a Specific Viewer
Photo Sharing Without a Specific Viewer
Photo Sharing Without a Specific Viewer
There are \(n\) users in a bidirectional social network. When the \(i\)th user shares a photo with a friend \(j\), not only does \(j\) see the photo, but every friend of \(j\) (including \(j\) itself) can also see it.
Now, user \(u\) intends to share a photo, but he does not want user \(v\) to see it. Without sending the photo to himself, he wants to know the maximum number of friends he can send the photo to such that user \(v\) will never see it.
Note: A friend \(j\) is eligible if and only if \(j\) is a friend of \(u\), \(j \neq v\), and \(v\) is not a friend of \(j\) (i.e. there is no direct connection between \(j\) and \(v\)).
inputFormat
The input consists of the following:
- The first line contains two integers \(n\) and \(m\) \( (1 \leq n, m \leq 10^5)\) representing the number of users and the number of friendship connections.
- The next \(m\) lines each contain two integers \(a\) and \(b\) (\(1 \leq a, b \leq n\)) indicating that user \(a\) and user \(b\) are friends. The friendship is bidirectional.
- The last line contains two integers \(u\) and \(v\) \( (1 \leq u, v \leq n, u \neq v)\) where user \(u\) wants to share the photo and does not want user \(v\) to see it.
outputFormat
Output a single integer representing the maximum number of friends user \(u\) can send the photo to without allowing user \(v\) to see it.
sample
4 3
1 2
2 3
3 4
1 3
0