#K54797. Taco Stack Operations
Taco Stack Operations
Taco Stack Operations
You are given n stacks, numbered from 1 to n, each initially having a value of 0. You need to perform m operations on these stacks. Each operation is represented by a pair of integers t and s, where:
- If t = 1, you increment the value of the sth stack by 1.
- If t = 2 and the sth stack is greater than 0, you decrement its value by 1. (If the sth stack is 0, the operation is ignored.)
Your task is to compute the final state of each stack after executing all the operations.
In mathematical notation, let \( S_i \) denote the value of the \( i^{th} \) stack (1 \( \leq i \leq n \)), initially \( S_i = 0 \). For each operation \( (t, s) \):
- \( t = 1 \): \( S_s \leftarrow S_s + 1 \)
- \( t = 2 \) and \( S_s > 0 \): \( S_s \leftarrow S_s - 1 \)
inputFormat
The first line contains two integers n and m, representing the number of stacks and the number of operations, respectively.
The following m lines each contain two integers t and s representing an operation, where t is either 1 or 2, and s (1 \( \leq s \leq n \)) is the stack index.
Input is provided via stdin.
outputFormat
Output a single line containing n space-separated integers, which represent the final state of each stack from stack 1 to stack n.
Output should be written to stdout.
## sample3 5
1 1
1 2
2 1
1 3
2 3
0 1 0