#P12035. Extracting Valid Flag
Extracting Valid Flag
Extracting Valid Flag
In the hackergame competition, extra characters might be mistakenly copied along with a flag when it is selected. To help, your task is to develop a program that reads a string and extracts a continuous substring that is a valid flag.
A valid flag is defined as a string that:
- Starts with
flag{
and ends with}
. - Contains, between
flag{
and}
, any visible characters except the characters{
and}
.
If there exists more than one valid flag, output the first one found in the input. If no valid flag can be found, output NOT FOUND
.
The mathematical form of the flag pattern can be represented in \( \LaTeX \) as:
[ f = \texttt{flag{}, X, \texttt{}} \quad \text{where} \quad X \in {\text{visible characters excluding { and }}}^* ]
inputFormat
The input consists of a single line that contains a string. The string may include spaces and other visible characters.
outputFormat
Output a valid flag found as a substring of the input. If multiple valid flags exist, output the first valid flag. If none is found, output NOT FOUND
.
sample
flag{this_is_valid}
flag{this_is_valid}