#K45722. Manage Artworks in Galleries
Manage Artworks in Galleries
Manage Artworks in Galleries
You are given a series of notices to manage the artworks in a museum. The museum consists of 3 galleries, and each gallery contains 5 rooms. Each notice is represented by three integers: g (the gallery number), r (the room number), and v (the value to add to the artworks in the room). After processing a notice, the number of artworks in the room is updated by adding v, but the number must always stay in the range \(0 \leq value \leq 20\).
Your task is to read the number of notices and process each notice accordingly. Finally, you should output the state of the galleries. The state of each gallery is output as a line of 5 numbers separated by spaces, and galleries are separated by a line of 20 dashes (--------------------
).
Notice: The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The first line contains a single integer \(n\) representing the number of notices. The next \(n\) lines each contain three integers \(g\), \(r\), and \(v\), where:
- \(g\) (1-indexed) denotes the gallery number (between 1 and 3).
- \(r\) (1-indexed) denotes the room number (between 1 and 5).
- \(v\) is the change in artworks (which can be positive or negative).
outputFormat
Output the final state of the galleries. For each gallery, print a line containing the number of artworks in its 5 rooms separated by a single space (a trailing space is acceptable). Between two galleries, print a line with exactly 20 dashes (--------------------
). There should be no separator line after the last gallery.
1
1 1 5
5 0 0 0 0
0 0 0 0 0
0 0 0 0 0
</p>