Good strings
Practice
3.3 (7 votes)
Combinatorics
Dynamic programming
Algorithms
String
Introduction to dynamic programming 1
Problem
91% Success 1775 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
There are N binary strings (consisting of 0s and 1s) in a table. A pair of strings is good if there exists at least one character in common in both strings.
Find the number of good pairs of strings.
Input format
- The first line contains an integer \(T\) denoting the number of test cases.
- The first line of each test case contains an integer \(N\) denoting the number of strings on the table.
- Next \(N\) lines of each test case contain the strings present on the table.
Output format
Print \(T\) lines. For each test case:
- Print a single line indicating the number of good pairs of strings.
Constraints
\(1 \leq T \leq 10000\)
\(1 \leq N \leq 100000\)
\(1 \leq Length\ of\ String \leq 5\)
The sum of length over all test cases does not exceed 500000.
Submissions
Please login to view your submissions
Similar Problems
Points:30
41 votes
Tags:
AlgorithmsDynamic ProgrammingGreedy Algorithms
Points:30
13 votes
Tags:
Dynamic ProgrammingAlgorithmsIntroduction to Dynamic Programming 1
Points:30
33 votes
Tags:
Easy
Editorial