cswork / OAOpen practice workspace

Capital OneOA #17

Get Function Execution Time

Estimated MediumJudge-ready

Topics (AI-labelled)Stacks & HeapsSimulation

Based on start/end logs sorted by time, compute the exclusive CPU time of each function; the timestamp at which a call ends is also counted.

Input

The first line contains n m; then m lines of function_id:start:timestamp or function_id:end:timestamp. The logs form a valid nested call sequence. This site adds timestamp≤1000000.

Output

Output n exclusive times, separated by spaces.

Example 1

Input:

3 6
0:start:0
2:start:4
2:end:5
1:start:7
1:end:10
0:end:11

Output:

6 4 2

Example 2

Input:

1 2
0:start:2
0:end:4

Output:

3

Example 3

Input:

2 4
0:start:0
1:start:1
1:end:1
0:end:2

Output:

2 1

Editorial

Loading solution…