Counting Bipartite Graphs
Practice
5 (3 votes)
Combinatorics
Easy
Graphs
Inclusion Exclusion
Math
Problem
87% Success 3062 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given two sets of vertices such that the first set contains $$n$$ vertices labeled $$1$$ to $$n$$ and the second set contains $$m$$ vertices labeled $$1$$ to $$m$$.
Add edges between these vertices such that no two vertices from the same set are adjacent and each vertex is incident on at least one edge. Find out the number of graphs that can be formed under the above constraints.
CONSTRAINTS:
\(1 \leq n \leq m \leq 10^6\)
INPUT:
A single line containing two integers $$n$$ and $$m$$.
OUTPUT:
A single integer denoting the answer. Since the answer can be large, output it modulo \(998244353\) .
Submissions
Please login to view your submissions
Similar Problems
Points:30
5 votes
Tags:
ApprovedCombinatoricsEasyMath
Points:30
4 votes
Tags:
CombinatoricsEasyInclusion-ExclusionMath
Editorial