#CCBCHHAI0000013. Ký tự hợp lệ Y hoặc N (First Y or N)
Ký tự hợp lệ Y hoặc N (First Y or N)
First Y or N
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Read non-whitespace ASCII characters in order, ignoring whitespace between characters. Only uppercase Y or N is accepted; lowercase y and n are not. Stop at the first accepted character. Output it and the total number of characters read, including the accepted character.
Input
A sequence of printable non-whitespace ASCII characters, optionally separated by spaces/newlines. The first uppercase Y or N is the last meaningful input character.
Output
Print the first accepted character, a space, and the number of characters read (excluding whitespace).
Subtasks
- Subtask 1 (20%): At most 5 printable non-whitespace ASCII characters.
- Subtask 2 (30%): At most 100 printable non-whitespace ASCII characters.
- Subtask 3 (50%): At most 100001 printable non-whitespace ASCII characters.
Examples
Example 1
Input
a y ? Y
Output
Y 4
Explanation
Read a, lowercase y, and ? as three invalid characters; uppercase Y is the fourth character and is accepted.
Example 2
Input
N
Output
N 1
Explanation
The first character N is accepted on the first read, giving count 1.