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

String concatenation

Time limit: 3000 ms
Memory limit: 256 MB
Given $n$ distinct strings $S_1,S_2,...,S_n$ and a target string $T$. Count the number of ways to concatenate the strings to form $T$, where each string can be used multiple times. ### Input - The first line contains an integer $n$. - The next $n$ lines each contain a string $S_i$. - The next line contains the string $T$. ### Output - Print an integer, the number of ways to concatenate modulo $10^9+7$. ### Constraints - $1 \leq n \leq 10^5$. - $1 \leq |S_i|, |T| \leq 10^5$. - $1 \leq \sum |S_i| \leq 5 \times 10^5$. ### Example Input: ### Example Input: ``` 3 a b ab abab ``` Output: ``` 4 ``` There are 4 possible concatenations: - `a` + `b` + `a` + `b` - `a` + `b` + `ab` - `ab` + `a` + `b` - `ab` + `ab`
Square root decomposition
Frequency
Tree query
Inversions query
Nearest vertex
Dominating color
String occurences 3
Inversions query 2
Pair
Sparse update
Tree
Range query
String concatenation
Subarray distance
Chameleon
Knapsack
Bit counting
Subsequence queries
Sub-subsequence
Delete numbers
Mode
Marisa is happy
Inversions query 3
Upperbound
23 path
Yet another square root decomposition problem
Marisa plays poker
Wonderful world
Topic
Dynamic Programming
Rating 1900
Solution (0) Solution