CBOJ 2023 Welcome Contest Problem 1 - Soccer League


Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

You are the director a soccer league with N teams in it. The last match was just played and you are trying to find out how many points each team has.

During the season, M games were played, the i-th game saw the ai-th team play against the bi-th (aibi). The result of the i-th game was recorded in the array r. If ri is 1 then the ai-th team won, if it is 0 then they drew, and if ri is -1 then the bi-th team won.

If a team wins a game, then they gain 3 points, if they draw, they gain 1 point, and finally if they lose, they gain 0 points.

For all N teams, compute how many points they ended the season on.

Constraints

1N100

1M1000

1ai,biN(aibi)

1ri1

Input Specification

The first line contains two integers N and M, which are the number of teams, and the number of games, respectively.

The i+1-th line contains three integers ai, bi, and ri, which are the index of the first team playing, the index of the second team playing, and the result, respectively.

Output Specification

Output N lines, where the i-th line contains the number of points the i-th team had at the end of the season.

Sample Input

Copy
4 5
2 3 -1
1 2 0
3 4 -1
3 2 1
3 2 -1

Sample Output

Copy
1
4
6
3

Explanation

Team 1: 0 / 1 / 030+11+00=1

Team 2: 1 / 1 / 231+11+02=4

Team 3: 2 / 0 / 232+10+02=6

Team 4: 1 / 0 / 031+10+02=3


Comments

There are no comments at the moment.