#K53167. DNS Record Validator
DNS Record Validator
DNS Record Validator
This problem requires you to validate DNS records that follow strict formatting rules. There are three types of records:
- A record: Must be in the format
A domain ip_address
, where ip_address is a valid IPv4 address (each octet is between 0 and 255). - CNAME record: Must be in the format
CNAME domain target
, where both domain and target follow valid domain name rules. - MX record: Must be in the format
MX domain preference target
, where preference is an integer between 0 and 65535.
A valid domain name is made up of labels separated by periods. Each label must satisfy the regular expression \( ^[A-Za-z0-9]([A-Za-z0-9\-]*[A-Za-z0-9])? \) which ensures that each label starts and ends with an alphanumeric character and may contain hyphens in between. The total length of the domain must not exceed 253 characters and each label must not exceed 63 characters.
inputFormat
The input is a single line read from stdin containing a DNS record string.
outputFormat
Output a single line to stdout: "True" if the DNS record is valid according to the rules, or "False" otherwise.
## sampleA example.com 192.168.1.1
True