cf/mirror

Alphabetic Tree

CF
1608G3500· legendary gm3s256 MB⌨ stdin/stdout

Examples

Sample 1of 2
Input
2 5 3
1 2 a
aab
abab
aaa
b
a
2 1 1 5
1 2 1 3
2 1 3 5
Output
8
7
4
Sample 2of 2
Input
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
Output
3
4
2
1
1
10
1608G.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…