cswork / OA打开练习工作台

其他OA #5

Exclusive Time of Functions (for E4 :)

估计中等可在线判题

考点(AI 标注)单调栈与堆字符串

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.

输入格式

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 n space-separated integers; item i is the exclusive execution time of function i.

样例 1

输入:

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

输出:

3 4

样例 2

输入:

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

输出:

8

样例 3

输入:

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

输出:

7 1