Please generate a unique JSON object suitable for automating the programming task testing platform, strictly in the following format:
{
"Title": "Task Name",
"Task Description": "Description of the task.",
"Function Signature": "def function_name(parameters) -> return_type:",
"Solve": "",
"Input": "Description of the input parameters.",
"Output": "Description of the expected output.",
"Examples": [
{
"input": "Example input here",
"output": "Expected output here"
},
{
"input": "Another example input here",
"output": "Another expected output here"
}
]
}
Ensure that:
1. The task includes graph traversal algorithms.
2. The JSON follows this exact structure and does not include any additional text or variations.
3. The task should be complex and unique, avoiding direct copying from common platforms like LeetCode or similar sources.
4. The solution must not use any imports in the code (i.e., no import statements).
5. The 'Solve' section must remain empty.
6. Ensure that the outputs are different each time by varying the problem constraints, examples, and overall structure of the task, so no two consecutive outputs are the same.
7. Include a unique aspect in each generated task, such as a specific mathematical concept, algorithm, or programming principle that distinguishes it from previously generated tasks.
8. The 'Function Signature' should strictly follow the format: 'def function_name(parameters) -> return_type:', but the 'Solve' section must remain empty. Ensure that the input description corresponds to the expected parameters in the signature.
Ensure that the solution must not be any of the following titles:
Hierarchical Lexicographic Sort
Alphanumeric Pattern Transformation
Custom Radix Sort with Base Conversion
Optimal Substructure Graph Traversal
Multi-Dimensional Array Spiral Sort
Nested List Sum with Depth Weighting
Prime Number Path in Graph
Decoding a Varied Mysterious Cipher
Unique Character Counter
Matrix Diagonal Sorting Algorithm
Minimum Cost Path in a Grid
Nested Palindrome Checker
Binary Tree Depth Sum
Bidirectional Merging Cascade
String Compression with Character Frequency
Custom Frequency-Based Sort
Nested Fibonacci Sequence Sum
Vowel Consonant Rank Encoding
Nested Polynomial Evaluation
Custom Tuple Sorting Challenge
Dynamic Subset Sum with Constraints
Dynamic Coin Change with Limited Supply
Nested Factorial Sequence Evaluation
Fractal Symmetry Pattern Reconnaissance
Dynamic Longest Palindromic Subsequence
Optimal Job Scheduling with Deadlines
Graph Cycle Detection with Unique Path Constraints
Assistant
json
Alternating Substring Transformation
Dynamic Maximum Subarray Product with Constraints
Custom Multi-Key Sort
Non-Linear Arithmetic Sort
Segmented Bucket Sort with Dynamic Range
Hierarchical Topological Sort
String Manipulation with Character Shifting
Custom Sorting with Weighted Criteria
Probability Path in Directed Graph
Dynamic Longest Increasing Subsequence with Constraints
Nested JSON Value Extraction
Dynamic Programming with Recursive Sum
Nested Interval Overlap Detection
Weighted Graph Shortest Path with Constraints
Sequential Alphabet Replacement
Weighted Depth-Limited Path Sum
String Transformation with Character Frequency
Dynamic Matrix Path Sum with Constraints
{
"Title": "Multi-Stage Shortest Path with Constraint Nodes",
"Task Description": "You are given a directed graph where each edge has a non-negative weight, a set of nodes called constraint nodes, and a start and end node. The task is to find the shortest path from the start node to the end node, such that the path passes through all the constraint nodes at least once. Return the length of this path. If no such path exists, return -1.",
"Function Signature": "def constrained_shortest_path(edges: List[Tuple[int, int, int]], n: int, start: int, end: int, constraints: List[int]) -> int:",
"Solve": "",
"Input": "A list of edges representing the graph where each edge is a tuple (u, v, w) meaning there is a directed edge from u to v with weight w, an integer n representing the number of nodes in the graph, start and end nodes as integers, and a list of integers representing the constraint nodes that must be included in the path.",
"Output": "An integer representing the length of the shortest path that visits all constraint nodes from start to end, or -1 if no such path exists.",
"Examples": [
{
"input": "edges = [(0, 1, 2), (1, 2, 2), (2, 3, 2), (0, 3, 7)], n = 4, start = 0, end = 3, constraints = [1, 2]",
"output": "6"
},
{
"input": "edges = [(0, 1, 4), (1, 2, 1), (2, 0, 3), (1, 3, 2)], n = 4, start = 0, end = 3, constraints = [2]",
"output": "7"
}
]
}