Binary sequences
Practice
4 (1 votes)
Dynamic programming
Algorithms
C++
3d dynamic programming
Problem
93% Success 209 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given three integers \(Z, O, K\).
Your task is to determine the number of distinct sequences of length \(Z + O\) that contains exactly \(Z\) zeroes and \(O\) ones. Also, the length of longest non-decreasing subsequence in the sequence is of length \(\ge K\).
Note
- Two sequences are said to be distinct if there exists at least one index where the value of element present is different in both sequences.
- A non-decreasing subsequence of \(a\) is a sequence of integers \(a_{p_1}, a_{p_2}, ... , a_{p_k}\) where \(p_1 < p_2 < .. < p_k\) and \(a_{p_1} \le a_{p_2} \le ... \le a_{p_k}\).
Input format
- The first line contains an integer \(T\) that denotes the number of test cases.
- For each test case:
- The first line contains three space-separated integers \(Z , O , K\).
Output format
For each test case, print the number of distinct sequences that satisfy the provided conditions.
Note: The result can be a large value, print the output in modulo \(10^9 + 7\) format.
Constraints
\(1 \le T \le 10 \\ 1 \le K \le 10^2 \\ 1 \le Z, O \le 50\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
106 votes
Tags:
Dynamic ProgrammingOpenApprovedMedium
Points:20
24 votes
Tags:
ApprovedEasyImplementationOpenSorting
Points:30
1 votes
Tags:
Medium
Editorial