RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
ICPC00058

C. Ceiling Function

Unrated 레이팅 미적용
난이도
5s
시간 제한
1024MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Advanced Ceiling Manufacturers (ACM) is analyzing the properties of its new series of Incredibly Collap\(se-Pr\)oof 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 collap\(se-re\)sistance 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. Because, well, why should it not? To be precise, ACM takes the collap\(se-re\)sistance values for the layers, ordered from the top layer to the bottom layer, and inserts them o\(ne-by-on\)e 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 and shown in Figure C.1. Notice that the first prototype’s top layer has collap\(se- re\)sistance value 2, the middle layer has value 7, and the bottom layer has value 1. The second prototype has layers with collap\(se-re\)sistance 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. (2, 7, 1) (3, 1, 4) (1, 5, 9) (2, 6, 5) (9, 7, 3) Figure C.1: The four tree shapes induced by the ceiling prototypes in Sample Input 1.

제약
입력 형식

The first line of the input contains two integers \(n\) (\(1 \le n \le 50\)), which is the number of ceiling prototypes to analyze, and \(k\) (\(1 \le k \le 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 collap\(se-re\)sistance values of the layers in a ceiling prototype, ordered from top to bottom.

출력 형식

Display the number of different tree shapes.

예제 1
입력
5 3
2 7 1
3 1 4
1 5 9
2 6 5
9 7 3
출력
4
예제 2
입력
3 4
3 1 2 40000
3 4 2 1
33 42 17 23
출력
2
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC World Finals 2016

평가 및 의견

C. Ceiling Function

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

C. Ceiling Function

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8