Question: Hello, please help me with my data structure HW using C++ programming language. Please kindly follow the instruction, and do not use the library bits/stdc++.h,

Hello, please help me with my data structure HW using C++ programming language. Please kindly follow the instruction, and do not use the library bits/stdc++.h, conio.h and limit.h. Thanks a lot!

Hello, please help me with my data structure HW using C++ programminglanguage. Please kindly follow the instruction, and do not use the library

Train stations Description Along a unidirectional railway (i.e. all the trains run in same direction}, there are n train stations numbered 1 . . . n. All the stations have their own rank, the lowest of which is ranked 1. Currently, there are some trains running on this railway. All of the trains should fulll such a requirement: If this train stops at station 3:, it should also stop at all the stations between start station and destination station (these two included) that have a rank not lower than station m's rank. For example, the table below shows a running schedule of 5 trains. In the table, D, S, F stand for departure station, stop station, final station respectively. Train 1, 2, 3 and 4 all fulll the requirement. However, train 5 stops at station 3 (rank 2) but doesn't stop at station 6 (also rank 2), so it doesn't fulll the requirement. The number of . . 1 2 3 4 5 6 7 8 train station The level of train station Train 1 D ; ; : S _> _> _> 5 _. F Train 2 D > _> _> 5 _. F Train 3- D 1 1 :I a > > > S r > > > F Train 4 D ' 5 ' 5 ' S _' F Train 5 D > > > S > > > > > F Now provide the schedule of m trains, all of which fulll the requirement. Please calculate at least how many different ranks can be assigned to these n stations. Input The first line contains two integers n, m, separated by a space. In the following m lines, the th line (1 g 'i g m) starts with one integer 3,: (2 S 3;: g n) denoting that the ith train has 3,: stations to stop. The following 3-; integers denoting the numbers of all the stations the train would stop. They are in increasing order and separated by spaces. It is guarantees that all the trains fulfill the requirement. Output One integer indicating at least how many different ranks can be assigned. Sample Input/Output Input 1 9 2 4 1 3 5 3 3 5 6 Output 1 2 Input 2 9 3 41 3 5 6 3 3 5 6 3159 Output 2 3 Constraints 1 { n, m

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!