0% found this document useful (0 votes)
60 views1 page

1 Purify en

Purify a text string by removing all occurrences of forbidden words from a list. The program takes a main string and list of strings to remove as input, finds and removes the shortest matching forbidden string at each step, and outputs the purified main string. It handles strings up to 105 characters consisting of digits and lowercase/uppercase English letters. Test cases demonstrate removing substrings from the main text.

Uploaded by

Vikram Saurabh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views1 page

1 Purify en

Purify a text string by removing all occurrences of forbidden words from a list. The program takes a main string and list of strings to remove as input, finds and removes the shortest matching forbidden string at each step, and outputs the purified main string. It handles strings up to 105 characters consisting of digits and lowercase/uppercase English letters. Test cases demonstrate removing substrings from the main text.

Uploaded by

Vikram Saurabh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Purify

CPSPC 2010 Prague, Day 1.

Submit: purify.c / purify.cpp / purify.pas


Input: stdin
Output: stdout

Time limit:
1s
Memory limit: 64 MB
Points:
100

Your task is to clean all the mess (the list of the forbidden words) in your room (text string).
Task:
Write a program, which removes all occurences of the strings Ni from the string P . More precisely defined, until P
contains some of the strings Ni , you should take the shortest prefix of P , which contains some of the strings Ni and delete
the shortest string from Ni that this prefix contains.
Input:
On the first line, there is one string P , which consits of the digits and lower and upper case of the english alphabet.
The length of P is at most 105 . On the remaining lines of the input, there is always exactly one string Ni , which consints of
the digits and lower and upper case of the english alphabet. The overall length of all the strings Ni is also at most 105 .
Output:
On the only line of the output, write the rest of P after removing all Ni . You can assume, that the length of the rest
of P will be always at least 1.
Example:
input
Huffleklek
flek

output
Hu

input
0001
00
000

output
01

You might also like