#C500. Beautiful Playlist
Beautiful Playlist
Beautiful Playlist
You are given a playlist of songs. Each song is represented as a string. A song is considered beautiful if for every adjacent pair of characters in the song, the absolute difference of their ASCII codes is less than or equal to 1. In other words, for a song string S of length L, it is beautiful if for every i from 1 to L-1, the following holds:
\( |ord(S_i) - ord(S_{i+1})| \le 1 \)
An empty song is also regarded as beautiful. Given a playlist, your task is to determine for each song whether it is beautiful or not.
inputFormat
The input is read from standard input (stdin) and contains the following:
- The first line contains an integer n representing the number of songs in the playlist.
- The next n lines each contain a string representing a song. (A song can be empty.)
outputFormat
For each song in the playlist, output a line containing True
if the song is beautiful according to the above criteria, or False
otherwise. The output should be printed to standard output (stdout).
3
ABC
BAB
AC
True
True
False
</p>