标签: algorithm graph topological-sort
所以,我试图解决以下问题:
http://codeforces.com/contest/510/problem/B
答案 0 :(得分:1)
我会这样解决:
G
v1
v2
w1
prefix v1 suffix1
w2
prefix v2 suffix2
O(sum over a length of each word)