CF1608G.Alphabetic Tree
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given m strings and a tree on n nodes. Each edge has some letter written on it.
You have to answer q queries. Each query is described by 4 integers u , v , l and r . The answer to the query is the total number of occurrences of str(u,v) in strings with indices from l to r . str(u,v) is defined as the string that is made by concatenating letters written on the edges on the shortest path from u to v (in order that they are traversed).
输入格式
The first line of the input contains three integers n , m and q ( 2≤n≤105 , 1≤m,q≤105 ).
The i -th of the following n−1 lines contains two integers ui,vi and a lowercase Latin letter ci ( 1≤ui,vi≤n , ui=vi ), denoting the edge between nodes ui,vi with a character ci on it.
It's guaranteed that these edges form a tree.
The following m lines contain the strings consisting of lowercase Latin letters. The total length of those strings does not exceed 105 .
Then q lines follow, each containing four integers u , v , l and r ( 1≤u,v≤n , u=v , 1≤l≤r≤m ), denoting the queries.
输出格式
For each query print a single integer — the answer to the query.
输入输出样例
输入#1
2 5 3 1 2 a aab abab aaa b a 2 1 1 5 1 2 1 3 2 1 3 5
输出#1
8 7 4
输入#2
9 5 6 1 2 a 2 7 c 1 3 b 3 4 b 4 6 b 3 5 a 5 8 b 5 9 c ababa cabbb bac bbbac abacaba 2 7 1 4 2 5 1 5 6 3 4 4 6 9 4 5 5 7 3 5 5 3 1 5
输出#2
3 4 2 1 1 10