Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 KB | None | 0 0
  1. JERRYTOM:
  2. The result of the game is treewidth + 1.[2]
  3.  
  4. Hence the problem boils down to computing treewidth of a Chordal Graph.
  5.  
  6. Note that Treewidth computation is NP complete for general graphs and an FPT algo of it has complexity 2^{k^3}*poly(n) which is no good for practical purposes.
  7.  
  8. But for chordal graphs this is solvable.
  9.  
  10. Theorem : Treewidth(G) = min(MaxClique(H) - 1) over all chordal completions of graph G (This is true for any graph and not just chordal graphs).[3]
  11.  
  12. Since G is a chordal Graph , G is its own chordal completion and hence among all chordal completions , G has the minimum MaxClique size
  13.  
  14. So now the problem is just to compute the max clique for a chordal graph.
  15.  
  16. Theorem : Max clique for a chordal graph can be found in linear time.
  17.  
  18. Proof: A chordal graph has a perfect vertex elimination scheme.[4]
  19. That is , you can order the verteces of the graph as v_1,v_2,...,v_n such that the neighbourhood of v_i in subgraph G[v_i,v_{i+1},...,v_n] is a clique.
  20.  
  21. This shows that there are atmost O(N) max cliques and each of them can be easily found by going through each node and computing size of its neighbourhood with indices > its own index.
  22.  
  23. Hence the complexity is pretty much linear , there is also a much simpler method for computing clique of a chordal graph given in [5].
  24.  
  25. [1].http://logicomp.blogspot.in/2006/05/game-theoretic-characterization-of.html
  26. [2].https://pdfs.semanticscholar.org/820d/d95c833211be602d8da6458e42f6cc72e89f.pdf
  27. [3].https://en.wikipedia.org/wiki/Chordal_completion#Related_graph_families
  28. [4].https://en.wikipedia.org/wiki/Chordal_graph#Perfect_elimination_and_efficient_recognition
  29. [5].https://etd.ohiolink.edu/rws_etd/document/get/kent1208869783/inline
  30.  
  31.  
  32. SUBWAY:
  33.  
  34. consider using 2^k array on tree.
  35. We first let vertex 1 be the root.
  36. Then for every vertex V we precalculate fa[i][V], which is the node that:
  37. 1、is V's ancestor.
  38. 2、distance between it and V is 2^i. "^" means power here.
  39.  
  40. For every vertex V and integer tuple {i,x,y}, we calculate dp[V][i][x][y] which is the maximum cost of a path that:
  41. 1、starts from V
  42. 2、ends at fa[0][fa[i][V]]
  43. 3、has the edge between V and fa[0][V] with color x.
  44. 4、has the edge betweem fa[i][v] and fa[0][fa[i][v]] with color y.
  45.  
  46. Now we try to get dp[V][i][x][y] using values dp[V][i-1][x][z] and dp[fa[i-1][V]][i-1][z][y] for all z.
  47. Easy to see that dp[V][i][x][y]=max(for all possible z){dp[V][i-1][x][z]+dp[fa[i-1][V]][i-1][z][y]}.
  48.  
  49. Easy to see that it will get TLE.
  50.  
  51. Now we try to improve the calculation of DP.
  52. Let cnt[V] denote the number of different colors on edges betweem V and fa[0][V].
  53. We use (U,V) to denote the edge between U and V on our optimal path.
  54. For some vertex X, when cnt[X]>=3, we can see that: whatever colors other edges have, (X,fa[0][X]) can always take a color that is different from its neighbouring edges on the path.
  55. Thus for every X that cnt[X]>=3, we can imagine that there is only one edge (X,fa[0][X]) with some "magic color" that is different from colors of any other edge (even if another edges also has magic color).
  56. So now cnt[X] drops to 1.
  57.  
  58. If we do that to all the vertices, cnt[V]<=2 will be satisfied for every vertex V, and the time complexity of DP will drop to O(n log n), because V<=n, i<=log n, x<=2 , y<=2, and z<=2.
  59.  
  60. Now the problem is to answer query (U,V).
  61. first we divide path U-V into k smaller paths, and each of them has a length that equals some multiplication of 2.
  62. Easy to see that we can achieve k<=2 log n.
  63. Let ans[u][v][x][y] denote the the maximum cost of a path that:
  64. 1、starts from u
  65. 2、ends at fa[0][v]
  66. 3、has the edge between u and fa[0][u] with color x.
  67. 4、has the edge betweem v and fa[0][v] with color y.
  68. And for paths u-v and v-w we have:
  69. ans[u][w][x][y]=max(for all possible z){ans[u][v][x][z]+ans[v][w][z][y]}
  70. In this way we can merge two neighbouring paths among the k ones.
  71. By doing this k-1 times we get the answer of the whole path, ans[U][V][x][y].
  72.  
  73. Total complexity: O((n+q) log n).
  74. PDELIV:
  75. We can reduce this problem to the following: given n linear functions f_i(x) and O(m + sum k_i) queries of the following format:
  76. l, r, x -- find max(f_l(x), f_{l + 1}(x), ..., f_r(x))
  77. It's so because when we deny to buy pizza from k pizzerias, the others are divided to at most k + 1 segments.
  78.  
  79. To answer such queries we can build a segment tree, where in each node we will store a convex hull of the functions corresponding to the segment.
  80.  
  81. Building the segment tree: O(n log n). Answering the queries can be done in O((n + m + sum k_i) log n) by processing them offline.
  82.  
  83. O(n * sqrt(n)) passes, too. (sqrt decomposition instead of segment tree)
  84.  
  85. PFRUIT (pdf/download): https://dropmefiles.com/jZUUD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement