#P4452. [国家集训队] 航班安排

    ID: 3367 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2012WC/CTSC/集训队网络流费用流

[国家集训队] 航班安排

Description

Shenniu Airlines has KK airplanes. To simplify the problem, assume all airplanes are identical. In the world of Shenniu Airlines, there are NN airports, numbered 0N10 \cdots N-1, where airport 00 is the base. All KK airplanes are at airport 00 at time 00, may take off starting from time 00, and must return to airport 00 no later than time TT.

During one day, the company receives MM charter requests. Each request is: depart from airport aa at time ss, arrive at airport bb exactly at time tt, and earn a net profit of cc. In other words, if you assign an airplane at time ss at airport aa to this request, that airplane will appear at airport bb at time tt, and you will gain a net profit of cc.

Design a plan to maximize the total profit.

Input Format

  • The first line contains 44 positive integers N,M,K,TN, M, K, T, as described above.
  • The next NN lines each contain NN integers, describing an N×NN \times N matrix tt, where ti,jt_{i,j} is the time needed to ferry (empty flight) from airport ii to airport jj.
  • The next NN lines each contain NN integers, describing an N×NN \times N matrix ff, where fi,jf_{i,j} is the cost to ferry from airport ii to airport jj.
  • The next MM lines each describe one request with 55 integers: a,b,s,t,ca, b, s, t, c.

Output Format

Output a single line with one integer: the maximum profit.

2 1 1 10
0 5
5 0
0 5
5 0
0 1 0 5 10
5

Hint

  • For 10%10\% of the testdata, K=1K = 1.
  • For another 20%20\% of the testdata, K=2K = 2.
  • For all the testdata: 1N,M2001 \le N, M \le 200, 1K101 \le K \le 10, 1T30001 \le T \le 3000, 1ti,j2001 \le t_{i,j} \le 200, fi,j2×103f_{i,j} \le 2 \times 10^3, 0a,b<N0 \le a, b < N, 0stT0 \le s \le t \le T, 0c100000 \le c \le 10000, ti,i=fi,i=0t_{i,i} = f_{i,i} = 0, ti,jti,k+tk,jt_{i,j} \le t_{i,k} + t_{k,j}, fi,jfi,k+fk,jf_{i,j} \le f_{i,k} + f_{k,j}.

Translated by ChatGPT 5