logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

After celebrating the birthday inPurple Cow, USA has a stomachache. He starts to look for a bathroom.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Problem Description

There is a mystery in Alley 118.

Never order a medium rare steak in Purple Cow (紫牛).

After celebrating the birthday inPurple Cow, USA has a stomachache. He starts to look for a bathroom. However, it is the peak time for bathrooms, and thus there are lots of people waiting in multiple lines. After waiting in a line for a while, USA notices that the number of the people in front of him increases. Afterwards, he discover that they are all impolite USBs who would cut in line and stand after their friends if they have friends from thesame group that are already in the line.

There areMbathrooms with indices0, . . . , M−1, andKgroups of students with indices

0, . . . , K−1. Now you, a  DSA  STUDENT  (Super  Toilet &  Unbelievably Diligent  &  Extra

Noted Technician), would need to help USA simulate how these lines change. The following4 situations might happen and cause some changes to the lines.

enteri j m

USB with idjfrom groupicomes to  stand  in  linem(the  line  for  bathroomm).  Note that the USB is going to cut into the position after thelastperson in groupi. If no one in groupiis in that line, the USB is going to stand at the end of the line.

leavem

The last USB in linemwalks away.

gom

The first USB in linemgoes to use bathroomm.

closem

Bathroommis out of toilet paper and closes. So USBs in that line would move to the nearestopen bathroom with a smaller index. Since the bathroom is placed circularly for some unknown reasons (probably because the earth is round :-) ), USBs would search for the first open bathroom inM−1, M−2, . . .if all the smaller-indexed bathrooms have been closed.

When moving, USBs from the end of linemwould move first because they are closer to the end of the other line. So effectively the order in linemis reversed in the new line. Besides, all those USBs still keep the habit of cutting in likeentering when moving to another line.

 

Input Format

The first line contains three integersM,N,K, representingMbathrooms,Nsituations and

Kgroups. The nextNlines are formatted as follows.

enter, followed by three integersi j mseparated by spaces

leave, followed by one integerm

go, followed by one integerm

close, followed by one integerm

 

Output Format

You should outputMlines, with linemcontaining the ids of the USBs waiting for bathroom

mby their order in the line.

 

Constraints

1.1≤M, N, K≤10 6

2.1≤M•K≤10 6

3. every USB’s id isdistinctand ranges in[1,10 8]

4. There will be no invalid situations, such as entering/closing a closed bathroom or leav- ing/going from an empty line.

 

Subtasks

Subtask 1 (20 pts)

M= 1

N, K≤10 3

noclosesituation

 

Subtask 2 (20 pts)

1≤M, N, K≤10 3

1≤M•K≤10 4

noclosesituation

 

 

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Atharva PatilComputer science

835 Answers

Hire Me
expert
Chrisantus MakokhaComputer science

527 Answers

Hire Me
expert
AyooluwaEducation

637 Answers

Hire Me
expert
RIZWANAMathematics

644 Answers

Hire Me

Get Free Quote!

379 Experts Online