CF698E.Cron
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Sometime the classic solution are not powerful enough and we have to design our own. For the purpose of this problem you have to implement the part of the system of task scheduling.
Each task should be executed at some particular moments of time. In our system you may set the exact value for the second, minute, hour, day of the week, day and month, when the task should be executed. Moreover, one can set a special value -1 that means any value of this parameter is valid.
For example, if the parameter string is -1 59 23 -1 -1 -1, the problem will be executed every day at 23:59:00, 23:59:01, 23:59:02, ..., 23:59:59 (60 times in total).
Seconds, minutes and hours are numbered starting from zero, while day, months and days of the week are numbered starting from one. The first day of the week is Monday.
There is one special case that is treated separately. If both day of the week and day are given (i.e. differ from -1) to execute the task only one of these two (at least one, if both match this is fine too) parameters should match the current time (of course, all other parameters should match too). For example, the string of parameters 0 0 12 6 3 7 means that the task will be executed both on Saturday, July 2nd, 2016 and on Sunday, July 3rd, 2016 at noon.
One should not forget about the existence of the leap years. The year is leap if it's number is divisible by 400, or is not divisible by 100, but is divisible by 4. Each leap year has 366 days instead of usual 365, by extending February to 29 days rather than the common 28.
The current time is represented as the number of seconds passed after 00:00:00 January 1st, 1970 (Thursday).
You are given the string of six parameters, describing the moments of time the task should be executed. You are also given a number of moments of time. For each of them you have to find the first moment of time strictly greater than the current when the task will be executed.
有时经典解法并不足够强大,我们需要自行设计算法。本题要求你实现任务调度系统的一部分。
每个任务应在特定的时间点执行。在本系统中,你可以为秒、分钟、小时、星期几、日期(每月的第几天)以及月份分别设定精确值,以指定任务的执行时间。此外,还可以将某个参数设为特殊值 -1,表示该参数可取任意合法值。
例如,若参数字符串为 -1 59 23 -1 -1 -1,则任务将在每天的 23:59:00、23:59:01、23:59:02、……、23:59:59 共 60 个时刻执行(即该分钟内的每一秒均执行一次)。
秒、分钟和小时的编号从 0 开始;而日期(每月的第几天)、月份和星期几的编号则从 1 开始。每周的第一天是星期一。
存在一种需单独处理的特殊情况:若星期几与日期(每月的第几天)均被显式指定(即二者均不为 -1),则任务只要满足其中至少一个条件(若两个条件同时满足,也允许执行)即可执行(当然,其余所有参数仍须全部匹配)。例如,参数字符串 0 0 12 6 3 7 表示该任务将在 2016 年 7 月 2 日(星期六)中午 12:00 以及 2016 年 7 月 3 日(星期日)中午 12:00 执行。
切勿忽略闰年的存在。某年为闰年的判定规则如下:该年份能被 400 整除;或不能被 100 整除但能被 4 整除。每个闰年有 366 天(而非通常的 365 天),其二月有 29 天(而非通常的 28 天)。
当前时间以自 1970 年 1 月 1 日 00:00:00(星期四)起经过的秒数表示。
你将获得一个包含六个参数的字符串,用于描述任务应执行的时间点。同时,你还会获得若干个时间点。对每个给定时间点,你需要找出严格大于该时间点、且任务将首次执行的最早时间点。
输入格式
The first line of the input contains six integers s, m, h, day, date and month (0 ≤ s, m ≤ 59, 0 ≤ h ≤ 23, 1 ≤ day ≤ 7, 1 ≤ date ≤ 31, 1 ≤ month ≤ 12). Each of the number can also be equal to - 1. It's guaranteed, that there are infinitely many moments of time when this task should be executed.
Next line contains the only integer n (1 ≤ n ≤ 1000) — the number of moments of time you have to solve the problem for. Each of the next n lines contains a single integer t__i (0 ≤ t__i ≤ 1012).
输入的第一行包含六个整数 s、m、h、day、date 和 month(0 ≤ s, m ≤ 59,0 ≤ h ≤ 23,1 ≤ day ≤ 7,1 ≤ date ≤ 31,1 ≤ month ≤ 12)。每个数也可能等于 −1。题目保证存在无穷多个应执行该任务的时间点。
下一行仅包含一个整数 n(1 ≤ n ≤ 1000)—— 表示你需要求解的时间点个数。接下来的 n 行中,每行包含一个整数 ti(0 ≤ ti ≤ 1012)。
输出格式
Print n lines, the i-th of them should contain the first moment of time strictly greater than t__i, when the task should be executed.
输出 n 行,其中第 i 行应包含严格大于 t__i 的、该任务应被执行的最早时刻(即一阶矩)。
输入输出样例
输入#1
-1 59 23 -1 -1 -1 6 1467372658 1467417540 1467417541 1467417598 1467417599 1467417600
输出#1
1467417540 1467417541 1467417542 1467417599 1467503940 1467503940
输入#2
0 0 12 6 3 7 3 1467372658 1467460810 1467547200
输出#2
1467460800 1467547200 1468065600
说明/提示
The moment of time 1467372658 after the midnight of January 1st, 1970 is 11:30:58 July 1st, 2016.
1970年1月1日午夜之后的时刻 1467372658 对应于 2016年7月1日 11:30:58。
输入解题思路,AI测评打分。不知道怎么写?