All Tracks Algorithms Dynamic Programming Problem

Perfect Matching
Tag(s):

Algorithms, Dynamic Programming, Hard

Problem
Editorial
Analytics

Given a bipartite graph having N vertices in each part and M edges, find the number of perfect matchings in it modulo 4.

Input format:
First line consists of a single integer T denoting the number of test cases.
First line of each case consists of two space separated integers denoting N and M.
Each of the following M lines consists of two space separated integers u and v, denoting that there is an edge between vertex numbered u on the left side and vertex numbered v on the right side. Vertices on each side are enumerated independently starting from 0.

Output format:
For each test case, print a single number in a new line - number of perfect matchings modulo 4

Constraints:
\(1 \le T \le 10\)
\(1 \le N \le 50\)
\(0 \le M \le N * N\)
\(0 \le u, v \le N-1\)

SAMPLE INPUT
1
2 4
1 0
0 1
0 0
1 1
SAMPLE OUTPUT
2
Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

HackerEarth Collegiate Cup - Mirror Round

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?