Champion Contest

View as PDF

Submit solution


Points: 7
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

gunners101101 likes to play LOL (League of Legends). He currently has a list of champions, each with a value vi, denoting how good the champion is. If a champion has a higher value than another champion, va>vb, then a will win in a 1 on 1 fight with champion b.

However, due to some lore hidden in this game, some champions are friends with other champions, as such, they refuse to fight, and the result of their fight will be a draw.

You are given n champions, and k friendships. You are to find the number of champions each champion can defeat.

Input Specification

First line, two integers n and k, denoting the number of champions and number of friendships.

Second line, n space separated integers vi denoting the value of each champion.

Next k lines, two integers ai and bi, denoting that ai and bi are friends.

Output Specification

For each champion, output the number champions that they can defeat, output the answer on one line separated by spaces.

Constraints

  • 2n105
  • 0kmin(105,n(n1)2)
  • 1vi109
  • 1ai,bin
  • All pairs of ai and bi are unique, and aibi

Sample Input

Copy
4 2
10 4 10 15
1 2
4 3

Sample Output

Copy
0 0 1 2

Explanation for Sample Output

The first champion can only win against the second champion, but since they are friends, he cannot defeat any champion. The second champion has the lowest value, and thus he cannot defeat any other champion. The third champion can only defeat the second champion. The last champion can defeat all the champions except for the third champion, as they are friends.


Comments


  • 0
    edwinwaterloo  commented on July 20, 2020, 9:51 p.m.

    Why can't I use NumPy for my program?


    • 1
      planT_444  commented on Feb. 10, 2022, 2:58 p.m.

      im kind of late but i think it's a third-party library that's not a part of the standard python modules