CF1765L.Project Manager

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn employees at Bersoft company, numbered from 11 to nn. Each employee works on some days of the week and rests on the other days. You are given the lists of working days of the week for each employee.

There are regular days and holidays. On regular days, only those employees work that have the current day of the week on their list. On holidays, no one works. You are provided with a list of days that are holidays. The days are numbered from 11 onwards, day 11 is Monday.

The company receives kk project offers they have to complete. The projects are numbered from 11 to kk in the order of decreasing priority.

Each project consists of multiple parts, where the ii-th part must be completed by the aia_i-th employee. The parts must be completed in order (i. e. the (i+1)(i+1)-st part can only be started when the ii-th part is completed). Each part takes the corresponding employee a day to complete.

The projects can be worked on simultaneously. However, one employee can complete a part of only one project during a single day. If they have a choice of what project to complete a part on, they always go for the project with the highest priority (the lowest index).

For each project, output the day that project will be completed on.

Bersoft 公司共有 nn 名员工,编号从 11 到 nn。每名员工在一周中的某些天工作,其余天休息。你将获得每名员工的工作日列表。

日期分为常规工作日和节假日。在常规工作日,仅当某员工的工作日列表中包含当天对应的星期几时,该员工才工作;在节假日,所有员工均不工作。你将获得一个节假日列表,其中日期按自然数编号(即第 11 天为星期一)。

公司共收到 kk 个需完成的项目委托,项目按优先级降序编号为 11 至 kk(即编号越小,优先级越高)。

每个项目由多个部分组成,其中第 ii 个部分必须由第 aia_i 号员工完成。各部分必须按顺序完成(即只有在第 ii 个部分完成后,才能开始第 i+1i+1 个部分)。每个部分需耗时一天,由指定员工完成。

不同项目可并行推进。但一名员工在同一天内最多只能完成一个项目的一个部分。若某员工当天有多个项目部分可选,则总是优先选择优先级最高的项目(即编号最小的项目)。

对每个项目,请输出其完成的日期。

输入格式

The first line contains three integers n,mn, m and kk (1≤n,m,k≤2⋅1051 \le n, m, k \le 2 \cdot 10^5) — the number of employees, the number of holidays and the number of projects.

The ii-th of the next nn lines contains the list of working days of the ii-th employee. First, a single integer tt (1≤t≤71 \le t \le 7) — the number of working days. Then tt days of the week in the increasing order. The possible days are: "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday".

The next line contains mm integers h1,h2,…,hmh_1, h_2, \dots, h_m (1≤h1<h2<⋯<hm≤1091 \le h_1 \lt h_2 \lt \dots \lt h_m \le 10^9) — the list of holidays.

The jj-th of the next kk lines contains a description of the jj-th project. It starts with an integer pp (1≤p≤2⋅1051 \le p \le 2 \cdot 10^5) — the number of parts in the project. Then pp integers a1,a2,…,apa_1, a_2, \dots, a_p (1≤ax≤n1 \le a_x \le n) follow, where pip_i is the index of the employee that must complete the ii-th part.

The total number of parts in all projects doesn't exceed 2⋅1052 \cdot 10^5.

第一行包含三个整数 n,mn, m 和 kk(1≤n,m,k≤2⋅1051 \le n, m, k \le 2 \cdot 10^5)——分别表示员工人数、假期天数和项目数。

接下来的 nn 行中,第 ii 行描述第 ii 位员工的工作日安排。首先是一个整数 tt(1≤t≤71 \le t \le 7),表示该员工每周工作天数;随后是 tt 个按升序排列的工作日,取值范围为:"Monday"、"Tuesday"、"Wednesday"、"Thursday"、"Friday"、"Saturday"、"Sunday"。

下一行包含 mm 个整数 h1,h2,…,hmh_1, h_2, \dots, h_m(1≤h1<h2<⋯<hm≤1091 \le h_1 \lt h_2 \lt \dots \lt h_m \le 10^9)——表示所有假期日期。

接下来的 kk 行中,第 jj 行描述第 jj 个项目。该行以一个整数 pp(1≤p≤2⋅1051 \le p \le 2 \cdot 10^5)开头,表示该项目包含的子任务数量;随后是 pp 个整数 a1,a2,…,apa_1, a_2, \dots, a_p(1≤ax≤n1 \le a_x \le n),其中 aia_i 表示必须完成第 ii 个子任务的员工编号。

所有项目中的子任务总数不超过 2⋅1052 \cdot 10^5。

输出格式

Print kk integers — the jj-th value should be equal to the day the jj-th project is completed on.

输出 kk 个整数——第 jj 个值应等于第 jj 个项目完成的天数。

输入输出样例

  • 输入#1

    3 5 4
    2 Saturday Sunday
    2 Tuesday Thursday
    4 Monday Wednesday Friday Saturday
    4 7 13 14 15
    5 1 1 3 3 2
    3 2 3 2
    5 3 3 3 1 1
    8 3 3 3 3 3 3 3 3

    输出#1

    25 9 27 27

输入解题思路,AI测评打分。不知道怎么写?

首页