cswork / OAOpen practice workspace

OtherOA #5

Exclusive Time of Functions (for E4 :)

Estimated MediumJudge-ready

Topics (AI-labelled)Stacks & HeapsStrings

Compute the exclusive running time of each function on a single-threaded call stack. This source explicitly points to LC636; this site adds the standard log input protocol and constraints.

Input

The first line contains the number of functions n and the number of logs m; each of the next m lines is id:start:timestamp or id:end:timestamp. Site limits: 1≤n≤100, 0≤timestamp≤10^9; logs are valid and given in chronological order.

Output

Output n space-separated integers; item i is the exclusive execution time of function i.

Example 1

Input:

2 4
0:start:0
1:start:2
1:end:5
0:end:6

Output:

3 4

Example 2

Input:

1 6
0:start:0
0:start:2
0:end:5
0:start:6
0:end:6
0:end:7

Output:

8

Example 3

Input:

2 6
0:start:0
0:start:2
0:end:5
1:start:6
1:end:6
0:end:7

Output:

7 1

Editorial

Loading solution…