[ZJOI 2018]Line Graph


Difficulty Ratings

Idea Creativity: 5/5
Techniques Used: 3/5
Implementation : 5/5
Very hard problem, a lot of details in implementation too. However, I think that general idea is quite interesting and easy to understand:)

Problem Link

Link in simplified chinese by jiry_2

Simplified Statement

Consider a graph G. Create G as follows:
- each edge in G corresponds to each node in G
- build an edge between two nodes in G if their corresponding edge in G have a common endpoint
Let L(G)=G. Given a tree T with N5000 nodes and k9, find the number of nodes in Lk(T) modulo 998244353, where Lk(G) is the function L operated k times on G.

Solution

Define |G| as the number of nodes in G. Lets see what is |Lk(G)| for small k.
k=1: Number of edges in G.
k=2: Number of chains of 3 nodes in G.
k=3: Number of chains of 4 nodes in G + 3*(Number of stars of 4 nodes in G) + 3*(Number of cycles of 3 nodes in G) (correct me if wrong)
k=4: Some mess...
We realise that each node in Lk(G) corresponds to some connected component of size k+1, while there might be more than one node corresponding to the same component. As all induced subgraph in T is also a tree, we can formulate |Lk(G)| as follows:
Tiwiti
where Ti are trees that have k+1 nodes (author says rooted helps implementation), wi is the number of nodes that represent Ti in Lk(T), and ti is the number of induced subgraph of T that is equal to Ti. So we just have to find wi and ti.

Finding wi

You just have to compute |Lk(Ti)| and remove nodes in Lk(Ti) that represent only a subset of Ti, which can be done by inclusion-exclusion. This part is not the bottleneck of time complexity. The hard part is to compute |Lk(Ti)|. You can simulate your way till |Lk4(Ti)|, and optain a graph G. You then have to find L4(G) in O(no.ofedgesinG), which is possible and not too annoying...

Finding ti

You can do this with a very yucky dp... Like some bitmasks and yucky stuff
So then you can find all wi and ti, and plug into the formula to get the answer.

Comments

Hardest problem i've ever seen...

留言

張貼留言