Question: THIS PROGRAM SHOULD BE DONE IN C Programming Language! (5) Stony Brook University announced that the school will host a Mathematics Olympiad where four SUNY

THIS PROGRAM SHOULD BE DONE IN C Programming Language!

THIS PROGRAM SHOULD BE DONE IN C Programming Language! (5) Stony Brook

University announced that the school will host a Mathematics Olympiad where four

SUNY schools (Stony Brook, Buffalo, Albany, Westbury) are going to compete against

(5) Stony Brook University announced that the school will host a Mathematics Olympiad where four SUNY schools (Stony Brook, Buffalo, Albany, Westbury) are going to compete against each other. Since the team selection is very critical for this competition. Stony Brook University asked you to help in the team selection process. There is a long queue of students from all the four schools. Each student of a school has a different roll number. Whenever a new student will come, he will search for his schoolmate from the end of the queue. As soon as he will find any of the schoolmate in the queue, he will stand behind him, otherwise he will stand at the end of the queue. At any moment, you can ask the students, who is standing in front of the queue, to come and put his name in a red box and remove him from the queue. There are Q operations of one of the following types E x y: A new student of school x (1sxs4) whose roll number is y (1sy 50000) will stand in queue according to the method mentioned above D: you can ask the student, who is standing in front of the queue, to come and put his name in the red box and remove him from the queue Now Stony Brook University asked you to tell them the order in which student put their name. Write a program to print required order Note: Number of dequeue operations will never be greater than enqueue operations at any point of time Input Format First line contains an integer Q (1sQs100000), denoting the number of operations. Next Q lines will contain one of the 2 types of operations. Take input from console Output Format For each 2nd type (dequeue) of operation, print two space separated integers, the front student's school and roll number. Write output in the console Sample Input E 1 1 E 2 1 E 1 2 (5) Stony Brook University announced that the school will host a Mathematics Olympiad where four SUNY schools (Stony Brook, Buffalo, Albany, Westbury) are going to compete against each other. Since the team selection is very critical for this competition. Stony Brook University asked you to help in the team selection process. There is a long queue of students from all the four schools. Each student of a school has a different roll number. Whenever a new student will come, he will search for his schoolmate from the end of the queue. As soon as he will find any of the schoolmate in the queue, he will stand behind him, otherwise he will stand at the end of the queue. At any moment, you can ask the students, who is standing in front of the queue, to come and put his name in a red box and remove him from the queue. There are Q operations of one of the following types E x y: A new student of school x (1sxs4) whose roll number is y (1sy 50000) will stand in queue according to the method mentioned above D: you can ask the student, who is standing in front of the queue, to come and put his name in the red box and remove him from the queue Now Stony Brook University asked you to tell them the order in which student put their name. Write a program to print required order Note: Number of dequeue operations will never be greater than enqueue operations at any point of time Input Format First line contains an integer Q (1sQs100000), denoting the number of operations. Next Q lines will contain one of the 2 types of operations. Take input from console Output Format For each 2nd type (dequeue) of operation, print two space separated integers, the front student's school and roll number. Write output in the console Sample Input E 1 1 E 2 1 E 1 2

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 Databases Questions!