Skip to main content
Back to problems
Codeforces
Easy
Sets
Arrays
I Wanna Be the Guy

Determine whether every level in a game can be passed using the combined set of levels completed by two players.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.

Problem 469A

gfg
Problem Statement

Problem

A game has levels numbered from $1toton$.

Two players each know a list of levels they can complete. If we combine the levels known by both players, can we cover every level from $1toton$?

Return YES if every level appears in at least one of the two lists, otherwise return NO.

Goal

Check whether the union of the two players' level sets contains all levels from $1toton$.

Input Format

  • The first line contains an integer nn.
  • The second line contains an integer pp followed by pp distinct level numbers known by the first player.
  • The third line contains an integer qq followed by qq distinct level numbers known by the second player.

Output Format

  • Print YES if every level from $1toton$ is covered by at least one player.
  • Otherwise print NO.

Constraints

  • 1n1001 \le n \le 100 (typical for this problem)
  • Level numbers are in the range $1..n$
  • The listed levels for each player are distinct
Examples
Sample cases returned by the problem API.

Example 1

Input

4
3 1 2 3
2 2 4

Output

YES

Explanation

The combined levels are {1,2,3,4}, so every level is covered.

Example 2

Input

4
3 1 2 3
2 2 3

Output

NO

Explanation

Level 4 is missing from both lists, so not all levels are covered.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.