Entering edit mode

Computer vision...

We are constantly improving our machine learning models in order to provide better insights to our customers.

This time we developed a computer vision algorithm called Blossom which can tell in a closed environment that whether or not two people are related to each other or not, by looking at conversations between them.

To test the accuracy, we deployed this in Gurgaon office.

Gathering over a weeks of data, we got information list from our model that informs us that person 'a' and person 'b' are related to each other.

We understand that the people in same department are going to have more conversations with each other as compared to those in different department. Hence each item in list provided by model will have people from same department (people 'a' and 'b' belong to same department). The other conversations between the people from different departments will be ignored by model.

elated

Provided the list of "related" people from model, please write code to determine the number of departments in Gurgaon office, so that we can evaluate it against ground truth.

Print the number of departments in Gurgaon office as per given Information.

Format of input:

People will be denoted as integers for sake of simplicity.

First line contains number of people in Gurgaon office, n (integer).

Second line contains number of predictions by model, m (integer).

Next m lines contains x (integer) and y (integer), denoting that people x and people y are related to each other.

1<n<= 100

0<= m.<= (n*(n-1)/2

1 <= x <= n, 1 <= y <=n

```
Sample input
5
3
1 2
2 3
1 3
Sample output
3
```

Max. score: 50

Sprinkle has 2 variant of the product, an Enterprise Application and a Lite Application Given N code files connected by N-1 imports Le. they form a graph. Files with odd numbers are files of the Enterprise App and even numbers files belong to the Lite App. Each file has some initial complexity given by array complexity. Now there are Q migrations taken by some developers from file u to v.

As they migrate the code from file u to v, the complexity of files in between increases by x units.

Let P1, and P2 be the sum of the complexities of the files of Enterprise and Lite after Q migrations. You need to print the absolute difference between P1 and P2.

Note: It is guaranteed that the given graph is a tree and there is always one answer.

The first line contains N denoting no of files.

The second line contains N integers defining array complexity Le initial complexity of files.

The next N-1 line contains two integers u, v which denotes a import path joining files u and v.

The next line contains Q denoting the number of migrations taken by developers.

Each Q migration is defined by three integers a, b, and xi.e developers migrate the code file a to b and every file in path gains x complexity.

Print the answer representing the absolute difference of their complexities after Q migrations.

1≤ N ≤ 10^5 1 ≤ P, X ≤ 10^9

1_<Q≤10^6

```
Sample input
6
1 2 3 4 4 2
1 2
1 3
3 4
3 5
2 6
3
5 4 1
1 6 2
Sample output
2
```

We enjoy celebrating our success.

This time the venue was, the prestigious "Ambience Mall", Gurgaon. Everyone is dressed with best outfits that they have. Now we are waiting for the star of the show

The "Value Proposition" of our Engineering Team.

He is a guy who likes to add value. The best way to add value in a party is by interaction with other people and making them happy.

We know there are n people in party.

There is a certain level of happiness increase for the ith person when VP comes and does a "handshake" with them. Let us call this happiness as h_j for the ith person.

These are unique handshakes and performed in a tuple, with left hand of ith person and right hand of jth person Let us denote this handshake via tuple (1.).

This one handshake in increases the overall happiness of party by h_i+h_j. The increase in happiness is same for ith person when performed with either left or right hand.

The left and right hands can be of same person in a handshake. (i == j).

We are aware that there were exactly "m" handshakes performed by VP in party with no duplicates, all the ordered handshake tuples afe unique. [tuple (i,j) is different from (tuple (i,j) when i !=j]

Now, the question is: What was the maximum possible increase in happiness of party, if all handshakes were performed optimally?

First line contains interger N and M, denoting number o people in party and number of handshakes performed i party.

Second line contains N space separated integers representing the happiness increase of each person.

Constraints:

1 <= N <= 10^5.

1 <= M <= N*N.

Happiness increase for a person can be upto 10^5

```
Sample input
5 3
2 4 6 8 10
sample output
56
```

The handshake tuples are: (5.5). (5.4) and (4.5) Increasing the happiness by (1010) (108)

(8-10)=56

Loading Similar Posts

StraightForward question on Disjoint Set. Do union of all edges and print the no of connected components.