Answered step by step
Verified Expert Solution
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:
Endterm 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
V@stmist
Output Format
Print a single integer the minimum number of instructions to be updated.
#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 ;
Sample Testcase #
Testcase Input
Copy
Testcase Output
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