编程介的小学生 2017-03-06 03:14 采纳率: 17.4%
浏览 967
已采纳

Elevator Simulation

You are to simulate the movements of an elevator, which works according to the following rules:
The elevator stays 3 seconds for customers to get in or get out. If some customers want to get in and some want to get out, the elevator stays 6 seconds.

It takes the elevator 2 seconds to go one story upwards or downwards.

When there is no request for service, the elevator stays where it is. Namely, it is idle.

When the elevator is idle, and a request comes from upwards or downwards, it moves upwards or downwards. If a request comes from the story where it stays, the elevator opens its door to serve these customers.

When the elevator goes upwards or downwards, it keeps its direction until there is no request from upwards or downwards. However, it breaks off to let customers get out or pick up customers if necessary.

If the elevator is to go upwards or downwards, it does not accept customers intending to go upwards or downwards.

When the elevator can act more than one way according to aforementioned rules, it chooses the action with the highest priority. The priorities for actions, from the highest to the lowest, are:

let customers get out

let customers get in

go downstairs

go upstairs

Initially (at time 0), the elevator is in the 0th story, and it is idle. Given the requests, you are to output how the elevator moves in a designated interval. Suppose that each request comes at an integer second.

Input

The input begins in its first line with the number of stories of a building, and other two numbers representing an interval. These three numbers are separated by a blank.

Each of the following lines in the input consists of three numbers, N1, N2, and N3, representing a request coming from N2th story to N3th story at time N1.

A line of three 0's separates two test cases. After the last test case, there is a line containing three 0's.

Output

You have to output what the elevator acts at each second in the designated interval. Behind each case should be one blank line.

Sample Input

5 9 67
10 2 1
13 2 4
21 4 2
26 4 3
40 1 2
45 0 3
46 0 2
0 0 0
0 0 0

Sample Output

9: Idle at story 0
10: Going up to 1
11: Going up to 1
12: Going up to 2
13: Going up to 2
14: Let upstair-customers get in at story 2
15: Let upstair-customers get in at story 2
16: Let upstair-customers get in at story 2
17: Going up to 3
18: Going up to 3
19: Going up to 4
20: Going up to 4
21: Let customers get out at story 4
22: Let customers get out at story 4
23: Let customers get out at story 4
24: Let downstair-customers get in at story 4
25: Let downstair-customers get in at story 4
26: Let downstair-customers get in at story 4
27: Going down to 3
28: Going down to 3
29: Let customers get out at story 3
30: Let customers get out at story 3
31: Let customers get out at story 3
32: Going down to 2
33: Going down to 2
34: Let customers get out at story 2
35: Let customers get out at story 2
36: Let customers get out at story 2
37: Let downstair-customers get in at story 2
38: Let downstair-customers get in at story 2
39: Let downstair-customers get in at story 2
40: Going down to 1
41: Going down to 1
42: Let customers get out at story 1
43: Let customers get out at story 1
44: Let customers get out at story 1
45: Going down to 0
46: Going down to 0
47: Let upstair-customers get in at story 0
48: Let upstair-customers get in at story 0
49: Let upstair-customers get in at story 0
50: Going up to 1
51: Going up to 1
52: Let upstair-customers get in at story 1
53: Let upstair-customers get in at story 1
54: Let upstair-customers get in at story 1
55: Going up to 2
56: Going up to 2
57: Let customers get out at story 2
58: Let customers get out at story 2
59: Let customers get out at story 2
60: Going up to 3
61: Going up to 3
62: Let customers get out at story 3
63: Let customers get out at story 3
64: Let customers get out at story 3
65: Idle at story 3
66: Idle at story 3
67: Idle at story 3

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-03-12 02:49
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • zqbnqsdsmd 2017-03-06 19:43
    关注
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 vue-codemirror如何对指定行 指定位置的 字符进行背景颜色或者字体颜色的修改?
  • ¥15 有人会思科模拟器嘛?
  • ¥30 遇到一个的问题,请教各位
  • ¥20 matlab报错,vflux计算潜流通量
  • ¥15 我该如何实现鼠标按下GUI按钮时就执行按钮里面的操作的方法
  • ¥15 关于#硬件工程#的问题:我这边有个锁相环电路没有效果
  • ¥15 20款 27寸imac苹果一体机装win10后,蓝牙耳机和音响放歌曲卡顿断断续续.
  • ¥15 VB.NET 父窗体调取子窗体报错
  • ¥15 python海龟作图如何改代码使其最后画出来的是一个镜像翻转的图形
  • ¥15 我不明白为什么c#微软的官方api浏览器为什么不支持函数说明的检索,有支持检索函数说明的工具吗?