#P2712. 摄像头

摄像头

Description

There are nn cameras in a grocery store. These cameras are clumsy and can only capture fixed positions. A group of bold squirrels wants to rob the store. To avoid being recorded, the first thing they plan to do is to destroy the cameras.

To make it easier to destroy the cameras, the squirrels assign a unified set of IDs to all cameras and to all positions that any camera can monitor. A camera can be destroyed if and only if the position where it is located is not monitored by any other camera.

Your task is to determine whether it is possible to destroy all cameras. If not, output the number of cameras that remain undestroyed.

Input Format

The first line contains an integer nn, the number of cameras.

Lines 22 to n+1n+1 describe the cameras. Each line contains the camera’s position xx, the number of positions mm it can monitor, followed by mm numbers yy that are the positions this camera can monitor (once this camera is destroyed, these positions are naturally no longer monitored).

Output Format

If it is possible to destroy all cameras, output YES\texttt{YES}; otherwise, output the number of cameras that remain undestroyed (without quotes).

5
1 1 2
2 1 1
3 1 7
4 1 1
5 0

2

Hint

Constraints

  • 1n1001 \leq n \leq 100.
  • 0m1000 \leq m \leq 100.
  • 0x,y5000 \leq x, y \leq 500.

Translated by ChatGPT 5