Answered step by step
Verified Expert Solution
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!
(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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started