#P4540. [HNOI2006] 军机调度

    ID: 3479 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2006各省省选湖南枚举,暴力排序位运算,按位

[HNOI2006] 军机调度

Description

Caesar leads a mercenary troop of nn people who take jobs from the Venetian Trading House.

The troop is diverse: different people have different skills, and some have multiple skills.

The jobs vary a lot. Some require several people to cooperate; some can be done by a single person. Some are simple, take little time, and thus pay less; others are difficult, require many people to work together for a long period, and thus pay more. Each job lasts no more than one month. A person cannot work on two jobs at the same time, and cannot join or leave a job midway. However, a person may stay idle and do no job.

For a job that requires pp people, if the number of assigned people is x>px > p, then the payment becomes the original payment divided by (xp+1)(x - p + 1). If x<px < p, the job cannot be completed. Only people who are capable of a job may be assigned to that job.

Caesar holds a military meeting at the end of each month to summarize the results, pay everyone, and assign the next month’s jobs.

How should Caesar assign the jobs to maximize the total payment? What is the maximum total payment?

Input Format

  • The first line contains two positive integers nn and mm, separated by a space, where n<10n < 10 is the number of mercenaries and m<15m < 15 is the number of available jobs for the next month.
  • The next nn lines describe the capabilities of each mercenary. On line ii (corresponding to mercenary ii), the first integer kik_i satisfies 0kim0 \le k_i \le m and denotes how many jobs mercenary ii can perform. It is followed by kik_i distinct integers, the IDs of the jobs that mercenary ii can perform, separated by spaces.
  • The last mm lines describe the jobs. On line jj (corresponding to job jj), there are four integers bb, ee, pp, and rr, separated by spaces:
    • 0<b<320 < b < 32: the start day (this day is counted in the job duration),
    • 0<e<320 < e < 32: the end day (this day is also counted in the job duration),
    • p<10p < 10: the required number of people,
    • 0<r<1000000 < r < 100000: the payment for the job.

Output Format

The first line contains a single integer tt, the maximum total payment that can be obtained.

3 5
2 1 4
2 2 4
3 3 4 5
2 20 1 100 
1 18 1 200 
3 28 1 800 
21 30 3 1500 
19 21 1 400 
1800

Hint

Translated by ChatGPT 5