Find Set
Practice
5 (3 votes)
Algorithms
String searching
String algorithms
C++
Problem
74% Success 462 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given a set of \(N\) strings. Your task is to determine the minimum possible size of set \(S\) (\(S\) is a subset of \(N\) strings) such that it meets the following conditions:
- All \(N\) strings must be covered by set \(S\)
- A string \(P\) is said to be covered by the set \(S\) if either \(P\) exists in \(S\) or any substring of \(P\) exists in \(S\).
Input Format:
- First line contains an integer \(N\)
- Next \(N\) lines contains a string \(P\)
Output Format:
Print the minimum possible size of set \(S\) , which covers all the \(N\) strings.
Constraints:
\(1 \le N \le 500 \\ 1 \le |P| \le 500\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
9 votes
Tags:
String SearchingGreedy AlgorithmsAlgorithmsStringString Algorithms
Points:30
9 votes
Tags:
AlgorithmsString Manipulation
Points:30
8 votes
Tags:
String AlgorithmsAlgorithmsString Searching
Editorial