Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

End - term exams are approaching at MIT. Shreyas and his friends are worried because they haven't studied anything. Last semester, they devised a scheme:

End-term exams are approaching at MIT. Shreyas and his friends are worried because they haven't studied anything. Last semester, they devised a scheme: whenever a person learns a topic, they must teach it to someone else. Following this scheme, they were able to score well in exams, except for some students who didn't learn certain topics due some topic assignment issues in the scheme.
Now, they aim to refine the method by updating some (A, B) instructions, meaning person A has to teach the topic to person B as well.
With the end terms drawing near, hey want to determine the minimum number of instructions they need to update so that everyone learns all the topics. Help them.
Input Format
The first line of input contains an integer N representing the total number of students.
The second line of input contains an array of integers of length N representing their last year's styudy scheme where indices of the array represent A and the values in this inices represent B
8V0176@stmist
Output Format
+918009938000
Print a single integer - the minimum number of instructions to be updated.
2
6
8
9
10
11
12
#include estdio> include vector
#include ciostream
#include algorithm using namespace std;
int main)(
/* Enter your code here. Read input from STDIN. Print outgut a return 0;
Sample Testcase #0
Testcase Input
3
332
Copy
018009
Testcase Output

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_2

Step: 3

blur-text-image_3

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

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students explore these related Databases questions