A970.Timeline--Gold
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:128MB
题目描述
Bessie attended N milking sessions (1≤N≤105) over the past M days
(2≤M≤109). However, she is having trouble remembering when she
attended each session.
For each session i=1…N, she knows that it occurred no earlier than
day Si (1≤Si≤M). Additionally, Bessie has C memories (1≤C≤105), each described by a triple (a,b,x), where she recalls that session
b happened at least x days after a.
Help Bessie by computing the earliest possible date of occurrence for each
milking session. It is guaranteed that Bessie did not remember incorrectly; in
other words, there exists an assignment of sessions to days in the range
1…M such that all constraints from her memories are satisfied.
输入格式
- Test cases 2-4 satisfy N,C≤103.
- Test cases 5-10 satisfy no additional constraints.
输出格式
The first line of input contains N, M, and C.
The next line contains N space-separated integers S1,S2,…,SN.
Each is in the range 1…M.
The next C lines contain three integers, a, b, and x indicating that
session b happened at least x days after a. For each line, a=b,
a and b are in the range 1…N, and x is in the range 1…M.
输入输出样例
输入#1
Output $N$ lines giving the earliest possible date of occurrence for each session.
输出#1
4 10 3 1 2 3 4 1 2 5 2 4 2 3 4 4
说明/提示
1
6
3
8