【杂题乱写】2023-11-17
Graffiti board Warnings.
Tasks below are finished yesterday in Yuhui Che's room(When he was watching ugly girls.). I'll write the solution in this blog because the coding work was accomplished just now.
ARC163D
How to count SCCs? We are familiar to the way of divide \(\{1\dots n\}\) into two subsets and force edges between the two sets to be one-directed.
Thus we use \(f_{i,j,k}\) to represent the number of ways to divide points label 1~(i+j) into two sets with size \(i\) and \(j\) and k edges are directed from a small labeled one to a big labeled one(we'll call these good edges later).
To fullfill this DP chart,we add i+j+1 to either set 1 or set 2.Enumerate the good edges in their own sets(0i/0j as we don't really care about their inner structure.).If you insert i+j+1 into set 2,then i more good edge(s) arise.
Time complexity will be O(Poly(n)) and we don't really care about the exponent since \(n\le 30\).
CF1313D
Notice that every child can get at most 8 candies. So we can do bitmask DP while scanning line. Label those operations which currently cover this segment in a dynamic way(use a bin to record the unvisited 1~8)
You don't need to deal with all the events happened at some \(i\) together cause the length of such segment is \(0\)
CF461E
No Binary Search.But binary lifting!
If letters in \(\{A,B,C,D\}\) do not appear in the given string \(t\),they can't appear in the target string \(s\).
To minimize the operation number,one could just find the longest prefix of \(s\) appeared in \(t\) and delete it in \(s\). Repeat such process until \(s\) is empty.
To stop such extension process, DFS on a trie is all you need. Set \(dp_{s,f}\) be the least length of a string begining with character \(s\),ending with character \(f\) that does not appear in \(t\). We want the character \(f\) force the substring extension process to stop.
By using binary lifting with something similar to matrix mutiplication,we can easily obtain \(\rm DP_{i,s,f}\) which means the least length of a row of \(2^i\) strings. Greedily append the strings to get the operation number.
It's obvious that by choosing proper characters,we can force the length of the longest prefix mentioned above is always smaller than \(\log_4{|t|}+1\). So do not let the substrings of \(t\) with a length longer than the upperbound appears in your trie.
Encounter and Farewell
How do you confirm that there is a Spanning tree in the graph? For me that is you can reach any vertex in the graph from any starting point. Or you can say it's a connected graph.
Vertex \(y\) can be reached be \(x\) if and only if we can obtain \(y\) from \(x\) by xoring \(x\) with some numbers not appearing in \(\{A\}\). If we want \(x\) to reach all the numbers from \(0\) to \(2^n-1\),then the complementary set of \(\{A\}\) must be full rank. Check this with Linear basis.
To construct a answer,we just connect \(i\oplus v_j\) and get a spanning tree. Here \(v_j\) is the original number of j th(st/nd/rd) position in the linear basis.

浙公网安备 33010602011771号