链接:
https://ac.nowcoder.com/acm/contest/57361/D
来源:牛客网
Alice and Bob are playing a game. Initially, there is a set of string
S. Alice and Bob take turns to play, with Alice going first. Each turn, a pla
yer can choose a string s from S, remove it from S, and select a character c which appears in s. Then, they remove all occurences of character c from s and divide s into several substrings along these removed positions. They add all non-empty substrings to the set S. The player who cannot make any move loses.
You are now given a tree with n nodes. Each node contains a character. Let path(u,v) represent the string formed by concatenating the characters on the shortest path from node u to node v (including nodes u and v). There are q queries, and for each query, given nodes u and v, you need to determine the winner when S={path(u,v)}. If Alice wins, also output the number of ways to make the first move.