After having watched all eight Harry Potter movies in a week, Nikola finally realized how the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
After having watched all eight Harry Potter movies in a week, Nikola finally realized how the famous Elder Wand changes the wizard it obeys. If wizard A, whom the wand is currently obeying, is defeated by wizard B in a duel, then the wand will start obeying the wizard B. Nikola is now wondering what would happen if 26 wizards labeled with uppercase letters of the English alphabet from A to Z began fighting in duels for the fondness of the Elder Wand. If we know the label of the wizard that the wand had obeyed before all duels and the outcomes of all N duels that were held one after another, answer the following questions: 1. Which wizard did the wand obey after all N duels? 2. How many different wizards did the wand obey? Input The first line contains an uppercase letter of the English alphabet, the label of the wizard that the wand obeyed at the beginning. The second line contains an integer number N (1 ≤ N≤ 100), the number of duels from the text of the task. In the next N rows there are two different uppercase letters of the English alphabet Z1 and Z2 separated by a space, whereas the wizard with the label Z1 defeated the wizard with the label Z2 in the ith duel. Output In the first line print an uppercase letter of the English alphabet, answer to the first question from the task description. In the second line print an integer number, answer to the second question from the task description. Sample Input 1 A 3 BA C B DA Sample Output 1 C 3 Explanation for Sample Output 1 Before the first duel, the Elder Wand obeyed wizard A. After the first duel, it obeyed wizard B, and after the second wizard C. The third duel didn't change anything. Sample Input 2 N 5 DA NB BA C D FA Sample Output 2 N 1 Copy Copy Copy Copy Sample Input 3 X 4 A X B X ΧΑ DA Sample Output 3 X 2 Copy Copy After having watched all eight Harry Potter movies in a week, Nikola finally realized how the famous Elder Wand changes the wizard it obeys. If wizard A, whom the wand is currently obeying, is defeated by wizard B in a duel, then the wand will start obeying the wizard B. Nikola is now wondering what would happen if 26 wizards labeled with uppercase letters of the English alphabet from A to Z began fighting in duels for the fondness of the Elder Wand. If we know the label of the wizard that the wand had obeyed before all duels and the outcomes of all N duels that were held one after another, answer the following questions: 1. Which wizard did the wand obey after all N duels? 2. How many different wizards did the wand obey? Input The first line contains an uppercase letter of the English alphabet, the label of the wizard that the wand obeyed at the beginning. The second line contains an integer number N (1 ≤ N≤ 100), the number of duels from the text of the task. In the next N rows there are two different uppercase letters of the English alphabet Z1 and Z2 separated by a space, whereas the wizard with the label Z1 defeated the wizard with the label Z2 in the ith duel. Output In the first line print an uppercase letter of the English alphabet, answer to the first question from the task description. In the second line print an integer number, answer to the second question from the task description. Sample Input 1 A 3 BA C B DA Sample Output 1 C 3 Explanation for Sample Output 1 Before the first duel, the Elder Wand obeyed wizard A. After the first duel, it obeyed wizard B, and after the second wizard C. The third duel didn't change anything. Sample Input 2 N 5 DA NB BA C D FA Sample Output 2 N 1 Copy Copy Copy Copy Sample Input 3 X 4 A X B X ΧΑ DA Sample Output 3 X 2 Copy Copy
Expert Answer:
Answer rating: 100% (QA)
Python Read input initialwizard inputstrip numduels intinput cu... View the full answer
Related Book For
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell
Posted Date:
Students also viewed these programming questions
-
Create two PLC ladder logic diagrams that use PLC coils and contacts to seal outputs. Then, you will use the Logix Pro simulation software to create the PLC ladder logic diagrams and verify their...
-
For this problem, you will create a series of small snippets that illustrate the issues that arise when using functional units with different latencies. For each one, draw a timing diagram similar to...
-
In this exercise, you will create a program that displays the number of daily calories needed to maintain your current weight. The number of calories is based on your gender, activity level, and...
-
Think about someone you know who is an entrepreneur. What are the advantages of owning their own business? What are the disadvantages? Why did they start their business? What method did they use to...
-
What is the difference between an observational study and an experiment?
-
Which category of proposal, solicited or unsolicited, is more likely to succeed, and why?
-
The internal energy of an ideal gas is a function of (a) Temperature only (b) Pressure only (c) Volume only (d) All of these.
-
Several years ago, Westmont Corporation developed a comprehensive budgeting system for profit planning and control purposes. While departmental supervisors have been happy with the system, the...
-
4)The boom as shown is held by a cord which is attached 3/4 of the way up the boom. If the tension in the cord is 720 N, what is the weight of the boom? cord 5) What is the tension in the cord? cord...
-
You have recently been hired by Keafer Manufacturing to work in its newly established treasury department. Keafer Manufacturing is a small company that produces highly customized cardboard boxes in a...
-
Steven Loh started High5 Training Pte Ltd in 2021. The company provides motivational courses for the small and medium enterprises in Singapore. All its revenue is derived from fees earned from the...
-
Consider the following program int x%;B int main(int argc, char *argv[]) { } int y;B int* z = malloc(sizeof(int));); Please fill in the table below for possible memory segments (data, code, stack,...
-
ChemCo division has the following data: Sales are $650,000, variable expenses are $330,000 and fixed expenses are $280,000. The fixed costs are not avoidable and must be allocated to profitable...
-
The direct materials budget shows the following: Desired ending direct materials 19000 pounds Direct materials required for production 95000 pounds Beginning direct materials 14700 pounds The total...
-
Due to erratic sales of its sole product-a high-capacity battery for laptop computers-PEM, Incorporated, has been experiencing financial difficulty for some time. The company's contribution format...
-
In the manufacture of 9,200 units of a product, direct materials cost incurred was $173,900, direct labor cost incurred was $111,600, and applied factory overhead was $49,000. The total conversion...
-
You deposit $2,000 into an account that pays 3% per year. Your plan is to withdraw this amount at the end of 5 years to use for a down payment on a new car. How much will you be able to withdraw at...
-
What are the typical record-at-a-time operations for accessing a file? Which of these depend on the current file record?
-
The numbers array is a five-element one-dimensional int array. The following statement should display the result of raising the first array element to the second power: cout < < pow(nums[0], 2);....
-
Which of the following statements assigns the first three characters in the part variable to the code variable? a. code = part.assign(0, 3); b. code = part.substr(0, 3); c. code = part.substr(1, 3);...
-
In this exercise, you modify the program from Computer Exercise 23. If necessary, create a new project named Intermediate24 Project and save it in the Cpp8\Chap12 folder. Copy the instructions from...
-
Why do organizations conduct marketing research?
-
What are some of the issues that should be considered when conducting marketing research?
-
What is the main difference between a full-service and a limited-service supplier?
Study smarter with the SolutionInn App