시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
5 초 | 512 MB | 283 | 99 | 59 | 33.714% |
Wang Xiuhan has an initially empty undirected graph on n vertices.
Each vertex has a weight, which is a non-negative integer.
Also, he has m tuples (ai, bi, si), where 1 ≤ ai, bi ≤ n, ai ≠ bi, and si is a non-negative integer.
After that, he starts the following process:
After the process was completed, a misfortune happened... Someone stole his notepad! Can you help him restore all numbers efficiently?
The first line of input contains two integers n and m: the number of vertices in Xiuhan’s graph and the number of tuples he has (1 ≤ n, m ≤ 300 000).
The second line contains n space-separated integers, w1, w2, . . . , wn: weights of the vertices (0 ≤ wi ≤ 106).
The next m lines contain a description of Xiuhan’s tuples. Each of these lines contains three integers ai, bi, si (1 ≤ ai, bi ≤ n, ai ≠ bi, 0 ≤ si ≤ 106).
On the first line, print one integer: the number of integers Xiuhan wrote in the notepad.
On the next line, you should write all these integers in the order he wrote them.
5 5 1 4 3 4 0 4 5 5 3 1 1 2 5 2 4 3 1 4 1 4
4 2 3 1 4
3 5 3 2 2 1 2 6 1 2 6 1 2 3 1 2 6 2 3 6
2 3 5
Camp > Petrozavodsk Programming Camp > Summer 2019 > Day 2: 300iq Contest 2 F번
Contest > Open Cup > 2019/2020 Season > Stage 1: Grand Prix of Kazan F번