Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!

image text in transcribed

image text in transcribed

image text in transcribed

(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions