benchmarks.wiki / Public workspace
Humanity's Last Code Exam / 2016_C / Ceiling Function
Problem
Answer published by the source. Consult the official source to check your work against its answer.
question title
Ceiling Function
question content
## Problem Description
Advanced Ceiling Manufacturers (ACM) is analyzing the properties of its new series of Incredibly Collapse-Proof Ceilings (ICPCs). An ICPC consists of layers of material, each with a different value of collapse resistance (measured as a positive integer). The analysis ACM wants to run will take the collapse-resistance values of the layers, store them in a binary search tree, and check whether the shape of this tree in any way correlates with the quality of the whole construction.
To be precise, ACM takes the collapse-resistance values for the layers, ordered from the top layer to the bottom layer, and inserts them one-by-one into a tree. The rules for inserting a value are:
- If the tree is empty, make the root of the tree.
- If the tree is not empty, compare with the root of the tree. If is smaller, insert into the left subtree of the root, otherwise insert into the right subtree.
ACM has a set of ceiling prototypes it wants to analyze by trying to collapse them. It wants to take each group of ceiling prototypes that have trees of the same shape and analyze them together.
For example, assume ACM is considering five ceiling prototypes with three layers each, as described by Sample Input 1. Notice that the first prototype’s top layer has collapse-resistance value 2, the middle layer has value 7, and the bottom layer has value 1. The second prototype has layers with collapse-resistance values of 3, 1, and 4 – and yet these two prototypes induce the same tree shape, so ACM will analyze them together.
Given a set of prototypes, your task is to determine how many different tree shapes they induce.
## Input
The first line of the input contains two integers (), which is the number of ceiling prototypes to analyze, and (), which is the number of layers in each of the prototypes.
The next lines describe the ceiling prototypes. Each of these lines contains distinct integers (between 1 and , inclusive), which are the collapse-resistance values of the layers in a ceiling prototype, ordered from top to bottom.
## Output
Display the number of different tree shapes.
## Sample Input 1
Plain-text mathematical notation (without MathML)
## Problem Description Advanced Ceiling Manufacturers (ACM) is analyzing the properties of its new series of Incredibly Collapse-Proof Ceilings (ICPCs). An ICPC consists of n layers of material, each with a different value of collapse resistance (measured as a positive integer). The analysis ACM wants to run will take the collapse-resistance values of the layers, store them in a binary search tree, and check whether the shape of this tree in any way correlates with the quality of the whole construction. To be precise, ACM takes the collapse-resistance values for the layers, ordered from the top layer to the bottom layer, and inserts them one-by-one into a tree. The rules for inserting a value v are: - If the tree is empty, make v the root of the tree. - If the tree is not empty, compare v with the root of the tree. If v is smaller, insert v into the left subtree of the root, otherwise insert v into the right subtree. ACM has a set of ceiling prototypes it wants to analyze by trying to collapse them. It wants to take each group of ceiling prototypes that have trees of the same shape and analyze them together. For example, assume ACM is considering five ceiling prototypes with three layers each, as described by Sample Input 1. Notice that the first prototype’s top layer has collapse-resistance value 2, the middle layer has value 7, and the bottom layer has value 1. The second prototype has layers with collapse-resistance values of 3, 1, and 4 – and yet these two prototypes induce the same tree shape, so ACM will analyze them together. Given a set of prototypes, your task is to determine how many different tree shapes they induce. ## Input The first line of the input contains two integers n (1≤n≤50), which is the number of ceiling prototypes to analyze, and k (1≤k≤20), which is the number of layers in each of the prototypes. The next n lines describe the ceiling prototypes. Each of these lines contains k distinct integers (between 1 and 10⁶, inclusive), which are the collapse-resistance values of the layers in a ceiling prototype, ordered from top to bottom. ## Output Display the number of different tree shapes. ## Sample Input 1
Original LaTeX notation
## Problem Description Advanced Ceiling Manufacturers (ACM) is analyzing the properties of its new series of Incredibly Collapse-Proof Ceilings (ICPCs). An ICPC consists of \( n \) layers of material, each with a different value of collapse resistance (measured as a positive integer). The analysis ACM wants to run will take the collapse-resistance values of the layers, store them in a binary search tree, and check whether the shape of this tree in any way correlates with the quality of the whole construction. To be precise, ACM takes the collapse-resistance values for the layers, ordered from the top layer to the bottom layer, and inserts them one-by-one into a tree. The rules for inserting a value \( v \) are: - If the tree is empty, make \( v \) the root of the tree. - If the tree is not empty, compare \( v \) with the root of the tree. If \( v \) is smaller, insert \( v \) into the left subtree of the root, otherwise insert \( v \) into the right subtree. ACM has a set of ceiling prototypes it wants to analyze by trying to collapse them. It wants to take each group of ceiling prototypes that have trees of the same shape and analyze them together. For example, assume ACM is considering five ceiling prototypes with three layers each, as described by Sample Input 1. Notice that the first prototype’s top layer has collapse-resistance value 2, the middle layer has value 7, and the bottom layer has value 1. The second prototype has layers with collapse-resistance values of 3, 1, and 4 – and yet these two prototypes induce the same tree shape, so ACM will analyze them together. Given a set of prototypes, your task is to determine how many different tree shapes they induce. ## Input The first line of the input contains two integers \( n \) (\( 1 \leq n \leq 50 \)), which is the number of ceiling prototypes to analyze, and \( k \) (\( 1 \leq k \leq 20 \)), which is the number of layers in each of the prototypes. The next \( n \) lines describe the ceiling prototypes. Each of these lines contains \( k \) distinct integers (between 1 and \( 10^6 \), inclusive), which are the collapse-resistance values of the layers in a ceiling prototype, ordered from top to bottom. ## Output Display the number of different tree shapes. ## Sample Input 1
Code
5 3
2 7 1
3 1 4
1 5 9
2 6 5
9 7 3
## Sample Output 1
Code
4
## Sample Input 2
Code
3 4
3 1 2 40000
3 4 2 1
33 42 17 23
## Sample Output 2
Code
2
platform
atcoder
Discussion
No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
Source and history
initial import