report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Good string pairs - FlandreOJ: Flandre Online Judge

Good string pairs

Time limit: 1000 ms
Memory limit: 256 MB
A pair of strings is considered good if they have at least one common letter. For example, the pair abc and adc is good because they share the letters a and c. Conversely, the pair bc and def is not good because they have no common letters. Given $n$ strings, count the number of good string pairs. ### Input - The first line contains an integer $n$. - The next $n$ lines each contain a string. ### Output - Print the number of good string pairs. ### Constraints - $1 \le n \le 10^5$. - The strings consist of the first 15 letters of the alphabet and have a length of at most 10 characters. ### Example Input: ``` 4 abc def afg ed ``` Output: ``` 3 ```
Inclusion-exclusion principle
Divisibility
Divisibility 2
Coprime query
GCD pairs counting
Good string pairs
Permutation problem
Restricted equation
Moving through matrix
Restricted equation 2
Binary matrix 2
Permutation Counting 2
Topic
Math
Bitmasks
Rating 1500
Solution (0) Solution