#K46967. Valid Message Verification
Valid Message Verification
Valid Message Verification
You are given an integer m and a sequence of integers that represents a coded message. The message is considered valid according to the ancient Atrovia's dialect rules if and only if:
- The message contains every integer from 1 to \(m\) at least once.
- Every integer in the message is between 1 and \(m\) (inclusive).
Your task is to read the input from standard input, determine whether the message is valid, and print True
if it is valid and False
otherwise.
Examples
- For input with
m = 5
and message4 2 3 1 5
, the output should beTrue
. - For input with
m = 5
and message1 2 1 3
, the output should beFalse
(since some numbers between 1 and 5 are missing). - For input with
m = 3
and message7 2 3 1
, the output should beFalse
(since 7 is out of range).
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains a single integer \(m\), the highest number in the range.
- The second line contains a space-separated list of integers representing the message.
It is guaranteed that the input contains at least the value for \(m\); the message could be empty.
outputFormat
Output to stdout a single line containing either True
if the message meets the rules specified, or False
otherwise.
5
4 2 3 1 5
True