#P2823. 时间表

    ID: 1857 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2016福建省历届夏令营网络流福建

时间表

Description

Each person can only choose one of attending meetings, talking to customers, or working on research projects in any given hour. To improve efficiency, each hour must be devoted entirely to one of these tasks, and they cannot switch in the middle.

Xiao A lives in a strange place where a week has DD days, labeled from 11 to DD. To protect the employees' voices, person ii can talk to customers for at most LiL_i hours per week.

Meetings are pre-planned, and the times at which each person needs to attend meetings are fixed. The call service center can respond to customer calls for HH hours each day; for convenience, these HH hours are labeled from 11 to HH.

For each day and hour of the week, the number of customers connecting to the call service center is known. Therefore, Xiao A knows that on day ii at hour jj, exactly Ri,jR_{i,j} employees must be scheduled to talk to customers. If person kk has no meeting at day ii, hour jj and can take customer calls, then Fk,i,j=1F_{k,i,j}=1; otherwise Fk,i,j=0F_{k,i,j}=0.

Again, Xiao A's world is quite strange: not only might a week not have 77 days, but a day might also not have 2424 hours.

Xiao A needs to create a timetable for each employee. Since employees also need to eat and rest, there is a lunch break every day from LTbeginL_{\text{T}_\text{begin}} to LTendL_{\text{T}_\text{end}} inclusive. Xiao A must ensure that each employee has at least one hour within this interval during which they are neither in a meeting nor talking to customers, so that they can eat, rest, or do what they want.

If someone has neither a meeting nor customer calls in an hour, they can work on the company’s research projects during that hour, and this counts as working time. They might also work on their own projects, but that does not count as working time.

Xiao A wants to know whether it is possible to arrange such a timetable that satisfies all of the following:

  • Each person spends at most NN hours per day on meetings and customer calls.
  • Each person spends at most LiL_i hours per week talking to customers.
  • Each person has at least one hour during the lunch break when they are neither in a meeting nor talking to customers.
  • For day ii, hour jj, exactly Ri,jR_{i,j} people are talking to customers.

Input Format

The first line contains a positive integer TT, the number of testdata sets.

For each testdata set, the first line contains four integers P,D,H,NP, D, H, N, representing the number of people in the team, the number of working days per week, the number of hours per day during which the call service center can respond to customer calls, and the daily per-person limit on time spent on meetings and customer calls, respectively.

The next line contains PP integers, where the ii-th integer is LiL_i.

The next line contains two integers LTbeginL_{\text{T}_\text{begin}} and LTendL_{\text{T}_\text{end}}, representing the lunch break interval.

Then follow DD lines, each containing HH integers; on the ii-th line, the jj-th integer is Ri,jR_{i,j}.

Then follow PP blocks; each block has DD lines, and each line contains HH integers. In the kk-th block, the number on the ii-th line and jj-th position is Fk,i,jF_{k,i,j}.

Output Format

Output TT lines. For the ii-th testdata set, print Yes if a feasible schedule exists; otherwise, print No.

2
2 2 3 2
4 1
2 3
0 1 1
0 1 0
1 1 1
1 1 1
1 1 1
1 0 1
2 2 3 2
4 1
2 3
0 1 2
0 1 0
1 1 1
1 1 1
1 1 1
1 0 1
Yes
No

Hint

Constraints:

For 100%100\% of the testdata, the following hold:

1T5,1NH701 \leq T \leq 5, 1 \leq N \leq H \leq 70.

$1 \leq D, P \leq 70, 1 \leq L_i \leq N \times D, 0 \leq R_{i,j} \leq 15$.

$0 \leq F_{k,i,j} \leq 1, 1 \leq L_{\text{T}_\text{begin}} \leq L_{\text{T}_\text{end}} \leq H$.

Translated by ChatGPT 5