Closed Walks on Path of Four — Solution & Editorial
The (1,1) entry of the adjacency matrix's N-th power. Matrix exponentiation in O(V³ log N).
Complexity: O(V3 log N)
The (1,1) entry of the adjacency matrix's N-th power. Matrix exponentiation in O(V³ log N).
Complexity: O(V3 log N)